Delta Time going up, leak with nothing more than sprite?

Hi All,

I’m not sure I understand how codea is executing the sprite() function.

For example if I start a new project and only add these lines to the draw function:

sprite(“SpaceCute:Beetle Ship”,100,100,50,50)

print(DeltaTime)

When I run this the printed DeltaTime is going up? starting at about 0.01 (full 60fps) and after about 20 seconds getting to 0.1 (10fps).

Is the code adding a new sprite each time? It seems the longer it runs DeltaTime goes up so the draw function is taking longer with each run? I can’t see any releasing in other code examples, and each sprite has no reference, so I assume it’s only drawing one each time… which seems to be consistent with the reference for draw and setup etc.

I’m sure there is a simple answer?

Hi @ozcreations, I think it is the print() function. It is notoriously slow when you iterate… Try using text() instead.

Yes, putting print() in the draw() function is a sure way to grind your program to a halt.

ehh? even if it’s inefficient, it should be consistently inefficient? how is it they are stacking up? Does this mean all debugging will have to be written over the gfx etc?

You can use print(), but you should be judicious. For example, you can print in response to a touch.

By putting print in draw, you’re trying to execute it many, many times a second. It just clogs the pipeline.

@ozcreations it’s because the output buffer is never cleared — so it grows longer and iOS does not perform well when appending rapidly to textviews.

yep. run your program, then try pausing it and scrolling the text window. Nutty-slow.

it makes print() debugging pretty crippled, which is a shame - I’m old-school, that’s how I roll. We (meaning TLL :slight_smile: ) should find a way to fix that… (maybe print() goes to a regular buffer, then the window is updated maybe once a second, only with the last chunk of the buffer? dunno. but it would be nice to put a print() in a deep loop and not have the result be “program freezes forever”)