Soon, I will be tasked with making the correct memory profile for C / C ++ code, and will use CUDA to take advantage of GPU processing.
My initial thoughts were to create macros and operator overloads that would keep track of calls in malloc, free, delete, and new calls in my source code. I could just include a different header and use the __FILE__ and __LINE__
to print the memory calls to the log file. This type of strategy can be found here: http://www.almostinfinite.com/memtrack.html
What is the best way to track this usage in a linked third-party library? I guess I can pretty much track memory usage before and after function calls, right? In my macro / overload script, I can simply track the size of the requests to find out how much memory is being requested. How can I tell how much a third-party library uses? I also understand that tracking "for free" really does not give you any idea of how much code is used at any given time, since it does not necessarily return to the OS. I appreciate any discussion of this.
I really don't want to use any memory profiling tools like Totalview or valgrind, because they usually do a lot of other functions (checking boundaries, etc.) that seem to make the program very slow. Another reason for this is that I want it to be somewhat thread safe - the software uses MPI, I believe that it spawns processes. I am going to analyze this in real time so that I can flush log files or something that can be read by another process to visualize memory usage as the software starts up. It will also be primarily run on Linux.
thanks
Derek
source share