|
Constructor / Destructor calculator
When writing software, memory leaks can be a problem.
This program is designed to help you detect memory leaks in object oriented software.
This program can also be used in linear programming.
Downloads
Screenshots
Usage When writing software, memory leaks can be a problem. This program is designed to help you detect memory leaks in object oriented software. This program can also be used in linear programming.
What you do is write a method that will write a line to a text file with 3 space separated words. Then in all the objects you want to track, you use the method you created in the constructor and destructor.
The first word for a constructor must be "constructor", a destructor should be "destructor". The second and third words are generally used for object type and object name. For instance say you have a CPlayer class. And when you construct it you assign it the name "Rob". Then in the constructor you would want it to write "constructor CPlayer Rob", and the destructor should write "destructor CPlayer Rob". You do not need to specify a 3rd word. However specifying a 3rd word allows you to see which instance of the object is having problems. Each line must be separated by a new line.
"test2.log" is an example output from a game. When you open the "test2.log" file in cdcomp.exe you will notice CArrow::a1 (-1) and CAppWindow::message_box (1). This shows that 1 instance of CAppWindow was not destructed. Which instance? That's what the 3rd word is for, we can tell that the "message_box" instance of CAppWindow is where the problem lies, the "render_window" does not show up in the list because there are an equal number of constructors and destructors. If you want to see all the classes, even the ones that are working, choose "Show All". Now what does CArrow::a1 (-1) mean? Well it means that somehow an instance of CArrow was destructed more times than it was constructed. This usually only happens when you the programmer mess up the constructor logging, or when the instance name changes between construction and destruction.
Ok now for a "real world" example. "test1.log" is an actual log from a flash animation I created a while ago. There were many things happening at the same time on the screen and things were being created and destroyed all the time. I needed to save processing time, and things seemed to get slower and slower. My objects would execute until their animation was finished and then destroy themselves. So I needed to see if any objects just kept executing forever. Stepping through the code would have been a day long process. Reading the log file myself and using a scratch pad was out of the question. So I made this program, and as you can see my "scale" function keeps scaling "plank" forever, and not only that, but it scales 39 planks forever! This was a huge help because I thought the problem was happening earlier in the sm (smooth move) function. When I fixed the plank problem everything ran much more smooth.
If you like this program please send a message.
|