SRL Archive - Java Help and Tutorials

fre buffered image from memory?


m34tcode

2012-03-20 10:59:08

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

2012-03-21 13:53:23

And why is garbage collector doing it a problem? You can call the garbage collector yourself with System.gc();

m34tcode

2012-03-21 14:10:57

Ahhhh, Thank you. Trying that.

dwimage

2013-06-06 22:54:21

i will try, it seems great.:)

Brandon

2013-06-06 22:58:54

From: weequ
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

2013-06-06 23:06:46

From: Brandon
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

2013-06-06 23:17:28

Gahh did not notice that stupid spam bot.. I saw last post as "Today" and first thought "meh.."

Flight

2013-06-06 23:26:41

From: Brandon
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

2013-06-25 01:50:02

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.