[SDL] Memory leak, noes '-'

Started by
3 comments, last by glauberdmo 12 years, 7 months ago
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.
Advertisement
You allocate bullets but you never free them.

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 '-'
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.
If I've helped you in any way please push the reputation button, thanks!

Abstraction is my choice of words.
Portfolio: http://www.0x3a.com/
Blog: http://blog.0x3a.com/
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?

This topic is closed to new replies.

Advertisement