missing the obvious

I have an app that is working just fine, but I’m sure I’m not cleaning up the scene properly. The memory load is gradually rising and when I test on the Nook and Kindle Fire it takes up to seven seconds for the first scene to load. I’ve been searching, but I don’t see where there is clear (and simple) directions on how to clean a scene (and I’m using director). I have local objects, timers and global variables/images. Can anyone point me in the right direction?

Thanks [import]uid: 48122 topic_id: 24548 reply_id: 324548[/import]

How long is a piece of string?

How deep is a hole?

The answers to those questions are endless…

So, the obvious is break down your code to the basics, then post that so people can look at it.

Asking the question openly, can lead to basically anything, need a more focused set of criteria then I’m sure people will chime in (including me).

:slight_smile:

ng [import]uid: 61600 topic_id: 24548 reply_id: 99407[/import]

Every level of my game (16 of them) call a variety of images that come from different modules. For example: I reference an image like this: local image9 = pathDescription.image9 local path9 = pathHelp.path9 and later in the level I reference the image to show on the screen like this;

turn9 = "forward" counter=counter+1,image9("forward"), path9("forward"), playButton() I want to make sure that when I call the changeScene function any memory that was dedicated to those images is released. I also have timers (timer.performWithDelay (stuff here) that I want to make sure I release.

I’ve looked at some stuff for a clean function, but it didn’t really make sense to me, which is why I’m asking for basics. [import]uid: 48122 topic_id: 24548 reply_id: 99413[/import]

odd code there.

Not really sure what you were aiming at.
This image9, path9 thing screams ‘use an array!!!’ to me

General rules:

Using director, each scene is developed in a lua file of its own.
Each file has its own displayGroup
All images loaded to screen are added to that displayGroup.
When you change scene using Director, it handles feeing up all the references and listeners associated with the objects in that displayGroup.

If you have any system listeners created in that lua file, you should kill them off just before you change scenes.

Using an object from another lua file in the way you describe suggests that you have a reference that probably won’t go out of scope until the app ends.

[import]uid: 108660 topic_id: 24548 reply_id: 99459[/import]

Hi Jeff,

That code does in fact reference an array (which is located in a different .lua). Those images are separate .luas because there are 6 levels that reference the same stuff. I wanted to make sure I was clearing memory on those modules, but it sounds like Director is taking care of it. I had forgotten to remove listeners though, so that’s probably a big part of the problem.

Thanks
RT [import]uid: 48122 topic_id: 24548 reply_id: 99522[/import]