FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Memory leak?

 
Post new topic   Reply to topic     Forum Index -> Derelict
View previous topic :: View next topic  
Author Message
null_void



Joined: 11 May 2008
Posts: 4

PostPosted: Sun May 11, 2008 11:27 am    Post subject: Memory leak? Reply with quote

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

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
View user's profile Send private message
Cyborg16



Joined: 28 Apr 2007
Posts: 39

PostPosted: Mon May 12, 2008 5:33 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
null_void



Joined: 11 May 2008
Posts: 4

PostPosted: Mon May 12, 2008 9:31 am    Post subject: Reply with quote

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
View user's profile Send private message
Cyborg16



Joined: 28 Apr 2007
Posts: 39

PostPosted: Tue May 13, 2008 4:27 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
null_void



Joined: 11 May 2008
Posts: 4

PostPosted: Tue May 13, 2008 10:11 am    Post subject: Reply with quote

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
View user's profile Send private message
null_void



Joined: 11 May 2008
Posts: 4

PostPosted: Tue May 13, 2008 10:26 pm    Post subject: Reply with quote

So, building it under linux (gentoo, in my case), did get rid of the memory leak. Weird.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Derelict All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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