Using dfSplat to identify object leaks: Difference between revisions

m
readability
mNo edit summary
m (readability)
Line 1: Line 1:
=== Preface ===
=== Preface ===
One of the problems when developing a program which has a lot of dynamic objects is that you make sure that all the objects that are created are also destroyed after usage. If you don't remove them all after usage, you'll end up with memory leaks and those can be rather unpleasant as they cause problems that are hard to track down.
One of the problems when developing a program which has a lot of dynamic objects is, that you have to make sure that all the objects that have been created are also destroyed after usage. If you do not remove all of them after usage, then you end up with memory leaks. Memory leaks can be rather unpleasant as they cause problems which are hard to track down.


A couple of areas where you see a lot of usage with dynamic objects is when working with XML and JSON.
A couple of areas where you see a lot of usage with dynamic objects is when working with XML and JSON.
Line 35: Line 35:
</source>
</source>


As you can see we are creating 20 objects based on the cObject class and store the object ID's in Objects array.
As you can see we are creating 21 objects based on the cObject class and store the object ID's in Objects array.
Then there's some code we are not showing where the objects are used for whatever and finally we destroy the objects.
Then there's some code we are not showing where the objects are used for whatever and finally we destroy the objects.
But.. we only destroy objects with an even object ID, so we are leaking 10 objects on purpose here to display how it works.
But.. we only destroy objects with an even object ID, so we are leaking 11 objects on purpose here to display how it works.


=== How to run the application in dfSplat ===
=== How to run the application in dfSplat ===
Line 88: Line 88:
[[File:dfSplat-LeakyObjects-Object-Inspector-Second-stop.png]]
[[File:dfSplat-LeakyObjects-Object-Inspector-Second-stop.png]]


As you can see now, our 20 test objects have been created.
As you can see now, our 21 test objects have been created.


So far, not all that exciting.
So far, not all that exciting.