I have an extreme problem.
I have been working on a game for about two years(20000+ lines of code), and Lately I have been noticing a ton of memory leaks. The problem is that I cannot track every single one of them since my game is way too big...
I have searched around and noticed that CppCheck would be useful in my situation, but the problem is that since I am using windows, i cannot use CppCheck(which is for linux only).
I am wondering if maybe there is a library or plugin that is CppCheck's equivalent for windows, or maybe a way to use CppCheck on windows instead.
All of the possibilities that I have come up with, along with solutions to other's problems(such as using smart pointers for std::deque and such) imply that my program is small or the more fitting: rewrite my entire program, something that I -really- do not want to do...
IDE: Code Blocks 10.05
Compiler: MinGW 3.81 GCC 4.4.1
shared_ptr
, and converting to (owning) pointers usingrelease
in order to keep the program compilable. Keep repeating until you get rid of leaks or have no more raw pointers. – Ardreymalloc
/free
in your code a lot, ornew
anddelete
? – Ardreyshared_ptr
. The way I have mydeque
s coded are where the player is also added to the list of spawns, this way the skills and other objects can react to it just like any other NPC – Attestationshared_ptr
everywhere; I said start using it incrementally (starting at wherever you create new objects points), switching to raw pointers when you need to, by releasing theshared_ptr
and getting back a raw pointer. – Ardreymalloc/free
I did not know much about,new/delete
is what I use for almost every object I have in my game. Im doubting that the problem is with creating objects, I would say its more toward any type ofdeque
storage. – Attestationnew
and find where and when it isdelete
d in your source. If this really is your first project, it's unreasonable not to expect to rewrite large portions as your knowledge grows. – Orestedeque
toshared_ptr
. And for some reason, When changing anything toshared_ptr
it said that the object's name was not defined, meanwhile it was defined on that exact spot... – Attestationdeque
toshared_ptr
, which gave an error? It shouldn't be erroring like that. – Ardreystd::deque<Item*> ItemList
tostd::deque<std::tr1::shared_ptr<Item>> ItemList
. Also I am not sure as to keep Item* when changing toshared_ptr
– Attestationtr1
namespace, just thestd
namespace. – Oresteshared_ptr
a bit easier: shared_ptr question. with this I should be able to switch toshared_ptr
quickly and without much fail. One question though: When changing toshared_ptr
should it be inshared_ptr<Object>
format orshared_ptr<Object*>
format? with the first I am wondering if that will still work with variables with that type of pointer(e.g. Ogre::SceneNode*), since I use ogre3d – Attestation