Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (843)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Blogpost about the garbage collector and GPU resources  (Read 1882 times)
0 Members and 1 Guest are viewing this topic.
Offline tduindam

Senior Newbie

« Posted 2013-11-12 12:51:04 »

Hi all,

I just wrote a small blogpost about using the garbage collector for objects that have allocated GPU resources.

You can read it here:

I hope you find it interesting, and I'm curious to hear about other strategies that I could employ.

Offline StrideColossus
« Reply #1 - Posted 2013-11-12 14:41:39 »

Nice summary of the perils of the garbage collector Wink

I have a similar solution using weak references to GPU resources, but as you highlight there is no guarantee the GC will ever clean them up.  Unfortunately you still have manage those resources yourself, the focus of the code is purely on detecting orphaned VBOs, textures, etc. as a diagnostic, either periodically or as a dump when the app is closed down.
Offline tduindam

Senior Newbie

« Reply #2 - Posted 2013-11-13 15:21:17 »

Thanks :-).

Using this mechanism for keeping track of which objects aren't destroyed is a clever trick, maybe I'll add it to our engine.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gouessej
« Reply #3 - Posted 2013-11-13 16:05:29 »


The only guarantee the JRE makes on this matter is that this will happen before Java runs out of heap-space
I already mentioned that several times here and on Ardor3D's forum, it's up to you to manage the native memory, you can run out of memory on the native heap if there is still enough memory on the Java heap. I quoted a documentation of IBM about that several months ago.

I solved the problem by explicitly removing buffers that I know are no longer required from the GPU
I have done the same in TUER about a month, I call glDeleteBuffers and I release the native memory of the direct NIO buffer.

you shouldn’t try to to be too smart around resources allocated out of sight of the garbage collector
Actually, you can't be smart, you have to track those resources by yourself.

Julien Gouesse | Personal blog | Website | Jogamp
Offline tduindam

Senior Newbie

« Reply #4 - Posted 2013-11-13 18:08:14 »

I did see that post you mentioned, but I forgot all about it. A pity, for it would have saved me some time :-)

Minor difference is that I ran into problems with GPU memory instead of native buffers, but the cause is exactly the same. I was wondering if I should post on the Ardor forum to alert people about the problem, but now I see that you have already done so.
Pages: [1]
  ignore  |  Print  

EgonOlsen (37 views)
2018-06-10 19:43:48

EgonOlsen (20 views)
2018-06-10 19:43:44

EgonOlsen (39 views)
2018-06-10 19:43:20

DesertCoockie (186 views)
2018-05-13 18:23:11

nelsongames (122 views)
2018-04-24 18:15:36

nelsongames (121 views)
2018-04-24 18:14:32

ivj94 (861 views)
2018-03-24 14:47:39

ivj94 (122 views)
2018-03-24 14:46:31

ivj94 (758 views)
2018-03-24 14:43:53

Solater (139 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!