Jump to content
  • Advertisement
Sign in to follow this  
glauberdmo

[SDL] Memory leak, noes '-'

This topic is 2596 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I not see that my project is with memory leak of 0.5MB/s. And I don't know why my objects causes it

All functions draw() (line 88 at 92, main.cpp) is causing memory leak.

Share this post


Link to post
Share on other sites
Advertisement

You allocate bullets but you never free them.




I forgetten of comment it. If you get off the bullet event in bar.h, the memory like continues, is sure that it will cause too '-'

Share this post


Link to post
Share on other sites
Its not just one thing that causes it, there are a lot of things causing this. Try looking at how you allocate your objects and check if you actually delete all of them.

If you really can't find all the problems try using this, I use it whenever I really don't know what is going on, memory going out of bounds and overwriting in the heap causing it to corrupt seems to be an issue with my code from time to time.
http://members.gamedev.net/EvilSteve/JournalStuff/MemMgr.cpp
http://members.gamedev.net/EvilSteve/JournalStuff/MemMgr.h

Compile your project with this and see what the logs say.

Share this post


Link to post
Share on other sites
I found the focus of problem, that cause constant increase in use of memory.

2 methods that use TTF_RenderText_Solid
I don't know that if you have a surface and it need to change constantly, must clear the surface before.
And this is what I do. I had a Score counter and a Clock that changes everytime. After the blit of surface, I put a SDL_FreeSurface().

Thanks for all help :D

PS.: I see in another section that mark topics with [solved] is not recommend. Is valid this here?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!