PDA

View Full Version : fre buffered image from memory?



m34tcode
03-20-2012, 02:59 PM
I was creating a successor to wolygons path creator, its doing great, but im stuck on a snag.

In order to load a new map, i need to free the previous buffered image, but as far as I know, only the garbage collector can do that.

Is there another way to free heapspace and remove the old map from memory, or force the garbage collector to remove it?

weequ
03-21-2012, 05:53 PM
And why is garbage collector doing it a problem? You can call the garbage collector yourself with System.gc();

m34tcode
03-21-2012, 06:10 PM
Ahhhh, Thank you. Trying that.

dwimage
06-07-2013, 02:54 AM
i will try, it seems great.:)

Brandon
06-07-2013, 02:58 AM
And why is garbage collector doing it a problem? You can call the garbage collector yourself with System.gc();


This doesn't call GC :S This only gives GC a notification saying "Hey now would be a good time to do a sweep if you're up to it".. No?

I thought that GC only sweeps when it needs to/wants to, not when the user tells it to.


I usually do:


BufferedImage B = new BufferedImage(.......);
//Dispose any graphics used.

When finished:

B = null;
B = new BufferedImage(...);
System.gc(); //Just tells gc that now would be a good time to clean up the resource if no references are holding onto it.

Flight
06-07-2013, 03:06 AM
This doesn't call GC :S This only gives GC a notification saying "Hey now would be a good time to do a sweep if you're up to it".. No?

I thought that GC only sweeps when it needs to/wants to, not when the user tells it to.


I usually do:


BufferedImage B = new BufferedImage(.......);
//Dispose any graphics used.

When finished:

B = null;
B = new BufferedImage(...);
System.gc(); //Just tells gc that now would be a good time to clean up the resource if no references are holding onto it.

Lol I got a laugh out of this, a 15-month late response. :D

Brandon
06-07-2013, 03:17 AM
Gahh did not notice that stupid spam bot.. I saw last post as "Today" and first thought "meh.."

Flight
06-07-2013, 03:26 AM
Gahh did not notice that stupid spam bot.. I saw last post as "Today" and first thought "meh.."

Haha I'm gonna quote you on that. Yeah that spambot above you scoped out threads relating to the keyword "image" so it targeted this thread as well. So I laid the ban-hammer.

Edit:
Check out my awesome new signature. ;)

weequ
06-25-2013, 05:50 AM
Yeah brandon i already know that by now but thx anyways. And sorry for wrong info.

edit: I think that b = NULL is unnecessary if you are assigning it a new object right after that.