View Full Version : Freeing resources
03-02-2011, 10:06 AM
When programming normal OpenGL in C++ I always take care to wrap every OpenGL object (textures, VBOs, FBOs etc') with an automatic class that deallocates it on the destructor.
With WebGL As I understand it, the garbage collector does this for me when there are no more references to that object.
So is there any real benefit to calling deleteBuffer explicitly when I know I'm done with it?
03-02-2011, 03:20 PM
That said, garbage collection is an evil thing that's provided for the weak-minded! It's a pain in the butt that the garbage collector can trigger at any time and consume a huge chunk of your CPU budget with no way for you to schedule that...so, sadly, you're going to take occasional random memory hits no matter what you do.
yep I hate garbage collection also, I see these micro pauses during app execution that are caused by this.
One thing Ive found which helps is keep a few global structures around eg
var globalLS = new LINESEGMENT();
var globalVec3 = new Vec3();
when you want to use a temporary variable use one of these, instead of creating a local one
also firefox is terrible WRT garbage collection compared to chrome, eg from what I see, press F5 in FF it doesnt clear out all the used memory! thus after a few F5's your app is > 1GB! normally I cant go 1 hour without having to quit FF are restarting
03-02-2011, 04:35 PM
The only thing that I've found that properly ensures that you're getting all of your files freshly from the server is to go to the Tools/ClearRecentHistory... dialog, unchecking everything except "Cache", setting the "TimeRangeToClear" to "Everything" and hitting the "ClearNow" button.
Actually, I've found Chrome to be even more prone to holding on to stuff in the cache than Firefox and I've had to resort to exiting the browser and manually deleting all of the cache files! (Although this 'stuck cache' thing last happened to me several months ago - and it may be that it's fixed in more recent versions).
03-03-2011, 07:41 AM
FF garbage collector does seem to suck. This actually explains now the little hangs I get every few seconds.
Is there some tool or something that can tell me what is the garbage collector doing so I could know where to focus my efforts?
you code try profiling your code (with chrome) + looking at the tree view to see if its actually the GC thats actually causing the hangs.
Like I said try to use a few global variables (that wont get destroyed after use) instead of local variables
PS - Im more than a bit pissed of with chrome as its stopped working again with webgl (it crashes instantly, Im pissed off since I had enabled 'do not update chrome from the internet' thus it expressly ignored my command. Once I get it working again I think the only option is to firewall chrome completely from the internet.
chrome does seem to have far better memory usage than firefox.
from new restart of chrome/firefox
chrome ~60mb used -> Shift-F5 (or Ctrl-Shift-R) ~60mb + constant with each restart
firefox ~150mb used -> Shift-F5 (or Ctrl-Shift-R) ~250mb + steadly climbs with each restart
Update (should be an edit)
firefox beta 12 solves a lot of the memory issues. i.e you can now press F5 + current used memory gets cleaned up eventually, performance is also improved from the last version I tested ~30%.
Also chrome has started working again (no automatic updates must only be a suggestion not a command), so Ive now firewalled it from accessing the internet :)
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.