|
|
|
|
Best/Fastest way to free accelerated memory?
Posted:
Sep 2, 2008 5:43 AM
|
|
|
Hi,
what is the best way to free accelerated memory?
I have several VolatileImage objects at the same time. When I don't need one of them anymore, I want it to be off the accelerated memory as fast as possible because I need the memory for an other image.
Is it enough to do something like this (if "image" is a VolatileImage object):
image = null;
Or is it better to call this (or does it make a difference, at all?):
image.flush(); image = null;
After the call "image=null;" is the accelerated memory freed immediately or will it not be frred until the garbage collector finally destroys my image object?
Are there any other possiblilities to free accelerated memory the fast way?
I hope you got some good hints for me concerning this problem because accelerated memory on my system is very rare.
Thanks, Maik
|
|
|
|
|
|
|
Re: Best/Fastest way to free accelerated memory?
Posted:
Sep 2, 2008 7:54 AM
in response to: kiamur
|
|
|
Maybe Chet Haase's post may help you? http://weblogs.java.net/blog/chet/archive/2003/09/volatileimage_q.html Q: What's with the extra null-check condition in createBackBuffer()?
As far as I understood after a quick read, flush() frees VRAM memory and nulling thus is superfluous. But nulling the reference possibly makes the java heap space faster available for the GC.
|
|
|
|
|
|
|
|
Re: [JAVA2D] Best/Fastest way to free accelerated memory?
Posted:
Sep 2, 2008 9:34 AM
in response to: kiamur
|
|
|
Hi,
for a VolatileImage flush() will release the associated vram immediately, so null-ing the reference would only help the GC to pick up the object.
However, for BufferedImage flush() will release only the vram-cached copies of the image, and not the java heap-based data buffer, so in this case setting the reference to null will definitely help to release the data quicker and may in fact prevent OutOfMemoryErrors if you're allocating images in a loop.
Thanks, Dmitri
java2d@JAVADESKTOP.ORG wrote: > Hi, > > what is the best way to free accelerated memory? > > I have several VolatileImage objects at the same time. When I don't need one of them anymore, I want it to be off the accelerated memory as fast as possible because I need the memory for an other image. > > Is it enough to do something like this (if "image" is a VolatileImage object): > > image = null; > > Or is it better to call this (or does it make a difference, at all?): > > image.flush(); > image = null; > > After the call "image=null;" is the accelerated memory freed immediately or will it not be frred until the garbage collector finally destroys my image object? > > Are there any other possiblilities to free accelerated memory the fast way? > > I hope you got some good hints for me concerning this problem because accelerated memory on my system is very rare. > > Thanks, > Maik > [Message sent by forum member 'kiamur' (kiamur)] > > http://forums.java.net/jive/thread.jspa?messageID=296688 > > =========================================================================== > To unsubscribe, send email to listserv@java.sun.com and include in the body > of the message "signoff JAVA2D-INTEREST". For general help, send email to > listserv@java.sun.com and include in the body of the message "help".
=========================================================================== To unsubscribe, send email to listserv@java.sun.com and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to listserv@java.sun.com and include in the body of the message "help".
|
|
|
|
|
|
|
|
Re: [JAVA2D] Best/Fastest way to free accelerated memory?
Posted:
Sep 2, 2008 9:35 AM
in response to: Dmitri Trembove...
|
|
|
Dmitri Trembovetski wrote: > > Hi, > > for a VolatileImage flush() will release the associated vram > immediately, so null-ing the reference would only help > the GC to pick up the object. > > However, for BufferedImage flush() will release only the
I should have said "managed image", since this applies to other types of images as well.
Dmitri
> vram-cached copies of the image, and not the java heap-based > data buffer, so in this case setting the reference to null > will definitely help to release the data quicker and > may in fact prevent OutOfMemoryErrors if you're allocating > images in a loop. > > Thanks, > Dmitri > > > java2d@JAVADESKTOP.ORG wrote: >> Hi, >> >> what is the best way to free accelerated memory? >> I have several VolatileImage objects at the same time. When I don't >> need one of them anymore, I want it to be off the accelerated memory >> as fast as possible because I need the memory for an other image. >> >> Is it enough to do something like this (if "image" is a VolatileImage >> object): >> >> image = null; >> >> Or is it better to call this (or does it make a difference, at all?): >> >> image.flush(); image = null; >> >> After the call "image=null;" is the accelerated memory freed >> immediately or will it not be frred until the garbage collector >> finally destroys my image object? >> >> Are there any other possiblilities to free accelerated memory the fast >> way? >> I hope you got some good hints for me concerning this problem because >> accelerated memory on my system is very rare. >> >> Thanks, >> Maik >> [Message sent by forum member 'kiamur' (kiamur)] >> >> http://forums.java.net/jive/thread.jspa?messageID=296688 >> >> =========================================================================== >> >> To unsubscribe, send email to listserv@java.sun.com and include in the >> body >> of the message "signoff JAVA2D-INTEREST". For general help, send >> email to >> listserv@java.sun.com and include in the body of the message "help".
=========================================================================== To unsubscribe, send email to listserv@java.sun.com and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to listserv@java.sun.com and include in the body of the message "help".
|
|
|
|
|
|
|
|
Re: [JAVA2D] Best/Fastest way to free accelerated memory?
Posted:
Sep 3, 2008 12:45 AM
in response to: Dmitri Trembove...
|
|
|
Hi,
thanks to both of you! I like reading the blog entries of Chet Haase, but I didn't know that one.
I really appreciate the good support and quality answers I get in this forum!
Regards, Maik
|
|
|
|
|