Memory Management for the New Year

First of all happy new year everyone. I have been working a great deal resolving design issues in Enigma. Most of which caused by me creating hacks to detect issues without a debugger. However there are a few that are just run of the mill oversights. While reviewing these I have been thinking allot about memory management.

Here is what I have come up with so far regarding what seems to work best. For starters using reference variables instead of pointers when possible saves you allot of risk regarding memory leaks. Although in some cases the best solution is a point in which case role with it don't try to hack around it. Also if you have to store virtual base classes in a collection use boost shared pointer. No cleanup and it will get the job done with few hassles.

So far using the stack for variables that last for the life of the application works pretty well. I then use the heap for temporary variables. I think DotNet has a similar memory management strategy and I can see the advantages to it in this project. For one I don't have to run cleanup code in my manager classes destructor code other than cleaning up remaining temp variables. If my temporary variables are shared pointers in a collection for example then they will get cleaned up all on there own.

I still would like to have some sort of garbage collection but I have yet to find a way to do it that is both portable and easy to add to the project. If I have to manually run make scripts on windows it just isn't worth it. However given the memory management strategies I have mentioned here the main places where garbage collection would be handy is the message objects which currently have their own special memory management which has thus far worked pretty well.

All in all things are going pretty well except for a few snags with 3rd party code and me going dll crazy. Alright that's all for now thanks for reading.

Comments

Popular posts from this blog

VK9 - Milestone8 Completed

VK9 - Milestone13 Completed

VK9 - Milestone16 Completed