Trying to diagnose a program that crashes over time

Hi there,

So, I have a simple program that generates a particle system to the stage, with about 100 particles, updating and rendering them at 30fps. Nothing too heavy. CPU is fine, framerate is great, etc.

I am using Dev-C++. I can run this program many times (maybe 60 times or so), modifying code, etc. Then, at some point the EXE stops working. I launch the file, it opens correctly, generates a few particles, and then freezes, and I have to use Task Manager to kill the process. I can restart Dev-C++, close all other programs, all to no avail. The only way I can get the EXE to run again is to restart my PC. Then things are peachy again for another 60 or so runs. One other thing: if I comment out the calls to “ofCircle()” that actually render the particles to the screen, things run fine again with no restart (i.e. the update / math code runs fine, just the graphics code causes the program to freeze).

I’m not sure what could be happening here. Does this smell like a memory leak? A graphics card issue? Something else? How would I go about diagnosing this?

Thanks for your help!

Jonathan

hmm -

whenever I see voodoo with devc++ I recommend you try “clean all” - dev-c++ doesn’t always compile everything it needed to recompile – and if you change variables, #defines in h files, etc, you might wind up issues where some stuff is updated while others is not – just say “clean”…

about the freeze, could it be a bug in your code, such as an uninitialized variable? uninitialized variables are funny in c++, because they take whatever value is in that spot in memory - therefore, you get different values for the variable every time you run, and every once in a while, those variables values could be bad, bad bad.

I’ve never seen a program crash so bad that you have to restart, in any compiler, on any system. I’d be super curious if you could post it as a zip.

thanks
zach

Hey Zach,

Sure, here you go: http://number27.org/download/OF/bubbles.zip (4.9MB)

You’ll need to copy “ofVectorMath” into your “libs” folder and add the path to your include list.

Again, the program runs fine for a while and finally starts freezing after 50 or so runs. Do you see anything suspicious in there? Sorry if things are convoluted – it’s the beginnings of a larger project.

Thanks.

Jonathan

One other thought… each time I run the EXE and close it, I get a windows “Application Error” message, saying:

The instruction at “0x00586a25” referenced memory at “0x00cb3bfc”. The memory could not be “read”. Click on OK to terminate the program

Is this normal? Or could this be part of the problem?

Is there some series of things I need to do in my code when the program ends? Garbage collection, freeing up memory, etc.?

Jonathan

Actually, disregard that last post. When I close the program by pressing “ESC”, it closes with no error. It’s only when I click the “Close” button in the Command Prompt window that I get the Windows error.

hi -

I’m sorry - the bug seems to be with us :frowning:

ofSetCircleResolution()

seems to leak memory if you call it every frame as you are doing - It’s allocating a call list for optimized drawing (in opengl, call list is very fast because it’s a pre-recorded set of opengl operations). We didn’t consider the memory or resource allocation costs of this because we never called it so often.

for now just don’t change the resolution in bubble.cpp:

  
  
// Render background dot  
if(timer > dots.size()){  
	//ofSetCircleResolution(50);  
	bg.draw();  
}  
  
// Reduce resolution for small dots  
//ofSetCircleResolution(15);  
  

and you should be fine. in the meantime and for 0.05 we will implement a small fix (calling the appropriate glCallListDelete as we need).

hope that helps -

zach

Thanks, Zach! That was indeed the problem! Is .05 coming soon?

By the way, I’m really starting to love C++ / OF! Performance is just incredible compared to Java / Processing.

Thanks for all your hard work supporting the community!

Jonathan