So i want to find out ways to track memory usage of APIs/Functions in C++.
Example GetData(structObj, *classObj);
If GetData() is leaking memory, it can leak only via structObj and *classObj as they are the only memory we have provided to it.
I need to track what is happening to the memory of structObj and *classObj inside GetData();
did you review the existing ones, like whatever Boehm's is these days - looks like it's now https://github.com/ivmai/bdwgc
I need to track what is happening to the memory of structObj and *classObj inside GetData();
statically or dynamically? Again, start by reviewing state-of-the-art leak checkers like MSVC's (static) and valgrind (dynamic).
Also, leak tracing is a very different job from garbage collection.
I personally think implementing garbage collection in C++ in counter productive, I don't want to distract you from you from plans of doing it, but from my humble experience I've seen it done mostly by people inclined to managed languages, usually in bigger projects (ex. unreal engine)
Garbage collection IMHO only adds unnecessary bloat to code negating language benefits, as if smart pointers are not good enough to achieve the goal, and reduce the possibility of leaks.
Thomas1965, gave you good suggestion how to start it, overloading new/delete to track memory allocations.
Anyway I've never done it myself so I my be wrong on this, but would really like someone to tell me what are the benefits and some good reasons and why it should be done compared to normal means of managing memory?