View previous topic :: View next topic |
Author |
Message |
null_void
Joined: 11 May 2008 Posts: 4
|
Posted: Sun May 11, 2008 11:27 am Post subject: Memory leak? |
|
|
I'm a bit of a beginner at this, so bear with me. I've just started using D in general, and wanting to do some graphics work, I found derelict. Very convenient.
So I whipped up a quick example for myself that renders nothing to a window, and it worked, making me happy. I happened to have the windows task manager open, and noticed that the memory usage was increasing without bound (though slowly).
Being a C++ programmer, I figured I had a memory leak somewhere, or hadn't turned on garbage collection, or something, even though everything I'd read seemed to indicate that this should be automatic.
So I started trying to narrow down what was causing it, and found that these two lines were responsible (or at least, seem to be).
Code: |
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapBuffers();
|
Disabling either one still results in continuous accumulated memory usage, but commenting both out fixes the problem. I figured maybe I was missing something, so I tried compiling and running the tutorial at http://dmedia.dprogramming.com/?n=Tutorials.SdlGlTutorial2, with the same results.
Has anyone else had this problem? Am I going crazy? My next step is to figure out how to do memory profiling with D/derelict, which is something I should get better at anyway.
Edit: It occurs to me that even if there is a memory leak, it may have everything to do with SDL and nothing to do with Derelict. Nonetheless, if anyone knows something about this... |
|
Back to top |
|
|
Cyborg16
Joined: 28 Apr 2007 Posts: 39
|
Posted: Mon May 12, 2008 5:33 am Post subject: |
|
|
Couldn't that be to do with your graphics-drivers supplied opengl libs? Just a suggestion; I'm really not an expert.
I have an SDL & OpenGL program which doesn't have any growing leaks. When run under valgrind there is a small memory leak mentioned, but the memory usage doesn't increase as its run.
One error I have found with SDL is that opening and closing joysticks without polling events causes a seg-fault. |
|
Back to top |
|
|
null_void
Joined: 11 May 2008 Posts: 4
|
Posted: Mon May 12, 2008 9:31 am Post subject: |
|
|
Could be. I guess I could experiment by writing the program in some other language. Maybe when I get home from work today. If you don't experience the problem, then clearly it's something specific to my setup, right? I could also try it under linux and see what happens... |
|
Back to top |
|
|
Cyborg16
Joined: 28 Apr 2007 Posts: 39
|
Posted: Tue May 13, 2008 4:27 am Post subject: |
|
|
null_void wrote: | If you don't experience the problem, then clearly it's something specific to my setup, right? |
No, there's far too many variables. Could be something to do with your code, the versions of the libraries you're using, the compiler (are you using dmd or gdc, and phobos or tango?), and probably other things too.
I tried the code in the tutorial you linked, using dmd v1.029, and didn't have any memory problems, so it's probably not the code. The sdl and opengl libraries I'm using are bound to be different to yours (I use debian linux & nvidia drivers), although it seems unlikely they'd be responsible... never-the-less you could try different versions, or if you used gdc try dmd. |
|
Back to top |
|
|
null_void
Joined: 11 May 2008 Posts: 4
|
Posted: Tue May 13, 2008 10:11 am Post subject: |
|
|
I'm working on setting up my project in my linux partition, so I'll see if that produces different results (once I figure out why it's trying to link in phobos rather than tango). I'm using the version of DMD that's packaged with tango, which I believe is the 1.x version. Thanks for the help. |
|
Back to top |
|
|
null_void
Joined: 11 May 2008 Posts: 4
|
Posted: Tue May 13, 2008 10:26 pm Post subject: |
|
|
So, building it under linux (gentoo, in my case), did get rid of the memory leak. Weird. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|