Disposing stuff - lazy but safe

Anything libgdx related goes here!

Disposing stuff - lazy but safe

Postby Doofus » Sun Jun 17, 2012 12:22 am

I understand that AssetManager with pause/resume loading unloading is the optimal way; I want to use the "lazy way"
But I dont want to have like undisposed resources that block memory even when my app is killed - should this even be possible? =/

Anyway, not using the AssetManager and stuff; I dispose everything in dispose().
When I close the app manually by using Gdx.app.exit(), dispose() is called, all fine.
But when the user presses the home button, only pause() is called.
Later Android may kill the app, and dispose() may actually be called, not sure, but the point is: most people like me are using task killer or launchers with task killers in them, like I use Go Launcher - and they will "kill all processes" -> dispose() is not called.

So is this alright ? Just disposing everything in dispose() ?
Doofus
 
Posts: 125
Joined: Sat May 05, 2012 11:35 am

Re: Disposing stuff - lazy but safe

Postby sephirothrx7 » Sun Jun 17, 2012 9:15 pm

As far as I know, Android behave just like Windows, Linux and etc. When a process is terminated, all the memory reserved for him wii be released, there's no need to worry. If I wrong, please someone correct me.
sephirothrx7
 
Posts: 16
Joined: Mon May 14, 2012 11:06 am

Re: Disposing stuff - lazy but safe

Postby sforzando » Mon Jun 18, 2012 2:54 am

I've notice that if I dismiss an app by sliding it off the open apps screen in Android 4.0, dispose is not called. Does this cause memory leaks or should I not worry about it?
sforzando
 
Posts: 59
Joined: Sun May 13, 2012 1:31 pm

Re: Disposing stuff - lazy but safe

Postby navossoc » Mon Jun 18, 2012 3:28 pm

sforzando wrote:I've notice that if I dismiss an app by sliding it off the open apps screen in Android 4.0, dispose is not called. Does this cause memory leaks or should I not worry about it?


I think you should not worry with memory leaks, because Android has a Garbage Collector too, so when more memory will be needed, it will be released.

I recommend that you try to dispose the resources whenever its possible, but, in the worst case, GC will do the job for you.

[]'s
navossoc
 
Posts: 16
Joined: Sat Jan 28, 2012 1:42 pm

Re: Disposing stuff - lazy but safe

Postby mzechner » Mon Jun 18, 2012 4:10 pm

It should not cause memory leaks if the app is killed without invoking your dispose() method. I have a very resource intensive app going with 200mb of memory used on average and never had a problem. Once the app is gone, all resources (including GLES objects) are reclaimed by the OS.
mzechner
Site Admin
 
Posts: 4715
Joined: Sat Jul 10, 2010 3:50 pm

Re: Disposing stuff - lazy but safe

Postby sforzando » Mon Jun 18, 2012 4:19 pm

Alright thanks.
sforzando
 
Posts: 59
Joined: Sun May 13, 2012 1:31 pm

Re: Disposing stuff - lazy but safe

Postby Doofus » Mon Jun 18, 2012 5:02 pm

Thats what we wanted to hear =D
Doofus
 
Posts: 125
Joined: Sat May 05, 2012 11:35 am


Return to Libgdx

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Yahoo [Bot] and 9 guests