@dave1707 - I’ve been playing around with a project recently and it started to crash, reported to @sim@John via the crash report, but I suddenly realised that it was a little bad coding from me. Not in my project as such it was down to garbage monitoring - I used print(collect.garbage()) - if you do so without using output.clear() it eventually slows down touch response etc and eventually leads to a crash.
I think what we need is a routine to collect garbage and print it out with a measure of the change in garbage size so that you can see the level and if it is increasing. What I’ve got in mind is fairly simple - have you already approached this ? got a routine sorted ?
Edit: tried this:
Put
garbageStart = collectgarbage()
at the end of setup(). Then called
function garbageMonitor()
--
local crap, diff
crap = collectgarbage()
diff = crap - garbageStart
output.clear()
print("Latest "..crap)
print(100*diff/garbageStart)
end
at the end of draw(), it fired out an answer of 0 and nan.
What on Earth is nan - definitely not my granny !!!
@dave1707 - that’s intriguing. The obvious text() instead of print, which is great during development - I should have thought of that.
The print(“uu”) had me a little puzzled, the problem with the print statement is it prints a line and carriage return so the scrollable output file printed can eventually cause an error or crash. Could Codea be built so that the output file has a finite length after which it fires up a message and stops printing?
Does the print(“uu”) involve no CR ? Or does it overwrite ? Can we convert output to strings and print that ?
Or is this some king of control character which doesn’t add a newline ?
All I got for that was the incrementing count if the draw() loop printed up.