The Source for Java Technology Collaboration

Home » java.net Forums » Java Desktop Technologies » Java 2D

Thread: Best/Fastest way to free accelerated memory?

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
This question is answered. Helpful answers available: 2. Correct answers available: 1.

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 4 - Last Post: Sep 3, 2008 12:45 AM by: kiamur Threads: [ Previous | Next ]
kiamur

Posts: 29
Best/Fastest way to free accelerated memory?
Posted: Sep 2, 2008 5:43 AM
 
  Click to reply to this thread Reply

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

bavarian

Posts: 7
Re: Best/Fastest way to free accelerated memory?
Posted: Sep 2, 2008 7:54 AM   in response to: kiamur
 
  Click to reply to this thread Reply

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.

Dmitri Trembove...
Re: [JAVA2D] Best/Fastest way to free accelerated memory?
Posted: Sep 2, 2008 9:34 AM   in response to: kiamur
  Click to reply to this thread Reply

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".


Dmitri Trembove...
Re: [JAVA2D] Best/Fastest way to free accelerated memory?
Posted: Sep 2, 2008 9:35 AM   in response to: Dmitri Trembove...
  Click to reply to this thread Reply

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".


kiamur

Posts: 29
Re: [JAVA2D] Best/Fastest way to free accelerated memory?
Posted: Sep 3, 2008 12:45 AM   in response to: Dmitri Trembove...
 
  Click to reply to this thread Reply

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




 XML java.net RSS