Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (578)
games submitted by our members
Games in WIP (498)
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 470 times)
0 Members and 1 Guest are viewing this topic.
Offline tduindam

Senior Newbie





« Posted 2013-11-12 13: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: http://goo.gl/izYWng

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

Cheers!
Offline StrideColossus
« Reply #1 - Posted 2013-11-12 15: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 16: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

« In padded room »



TUER


« Reply #3 - Posted 2013-11-13 17:05:29 »

Hi

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

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

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

Offline tduindam

Senior Newbie





« Reply #4 - Posted 2013-11-13 19: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  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (27 views)
2014-04-15 18:08:23

BurntPizza (22 views)
2014-04-15 03:46:01

UprightPath (38 views)
2014-04-14 17:39:50

UprightPath (20 views)
2014-04-14 17:35:47

Porlus (36 views)
2014-04-14 15:48:38

tom_mai78101 (61 views)
2014-04-10 04:04:31

BurntPizza (119 views)
2014-04-08 23:06:04

tom_mai78101 (219 views)
2014-04-05 13:34:39

trollwarrior1 (186 views)
2014-04-04 12:06:45

CJLetsGame (193 views)
2014-04-01 02:16:10
List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
java-gaming.org 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‑gaming.org
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!