473,385 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Tools to analyze memory usage within a program

Hi-

I'm wondering if anyone has run across any program for C++ development
that will help track the memory usage of different objects (class
instances) within a program. I find it's easy enough on various
platforms to get a handle on the total memory usage of your program for
different testcases. But what I'm interested in is finding out where the
memory usage is going within the program (sort of like how profiling
tools tell you the function/line number where your run-time is going). A
hierarchical report listing each class, the number of instances created
of that class, and the same info for each sub-class would be ideal. I've
generated this kind of info on a limited basis in the past simply by
adding instrumentation to the destructors of classes. But now I'm
dealing with a s/w system that is large enough I don't look forward to
doing that by hand!

Thanks,

-dm
Jul 22 '05 #1
2 4043
Dennis McCrohan wrote:
Hi-

I'm wondering if anyone has run across any program for C++ development
that will help track the memory usage of different objects (class
instances) within a program. I find it's easy enough on various
platforms to get a handle on the total memory usage of your program
for different testcases. But what I'm interested in is finding out
where the memory usage is going within the program (sort of like how
profiling tools tell you the function/line number where your run-time
is going). A hierarchical report listing each class, the number of
instances created of that class, and the same info for each sub-class
would be ideal. I've generated this kind of info on a limited basis
in the past simply by adding instrumentation to the destructors of
classes. But now I'm dealing with a s/w system that is large enough I
don't look forward to doing that by hand!

Thanks,

-dm


In standard C++ (the topic of this group) I believe the only way to do so is
to do something like this:

class C
{
static size_t count;
public:

C() { ++count; }
C(const C&) { ++count; }
~C() { --count; }

static size_t BytesUsed() { return sizeof(C) * count; }
};

For development tools, please ask on a group for your platform.

- Pete
Jul 22 '05 #2
Ian
Dennis McCrohan wrote:
Hi-

I'm wondering if anyone has run across any program for C++ development
that will help track the memory usage of different objects (class
instances) within a program. I find it's easy enough on various
platforms to get a handle on the total memory usage of your program for
different testcases. But what I'm interested in is finding out where the
memory usage is going within the program (sort of like how profiling
tools tell you the function/line number where your run-time is going). A
hierarchical report listing each class, the number of instances created
of that class, and the same info for each sub-class would be ideal. I've
generated this kind of info on a limited basis in the past simply by
adding instrumentation to the destructors of classes. But now I'm
dealing with a s/w system that is large enough I don't look forward to
doing that by hand!

This stuff, while useful, is non-standard and tool specific.

Your tool chain may or may not support this, search for it in your
documentation.

You could write your own allocator and call it through macros passing in
file and line info. I did this once and it worked well.

Ian
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Tom | last post by:
We have a VERY simple .NET C# Form Application, that has about a 23MB Memory Footprint. It starts a window runs a process and does a regular expression. I have done a GC.Collect to make sure that,...
2
by: Jarvis | last post by:
I've made a testing program to test the memory usage of some Data Forms. I create a MDI parent form with one single MDI child form, which is a Data Form generated by .NET Data Form Wizard. To...
12
by: ira2402 | last post by:
Hi All, We are developing sw for a small embedded OS and we have limited memory. We are looking for algorithms, links, and articles about this. The goal is efficient utilization of small amount...
1
by: Kovan Akrei | last post by:
Hi, I have a multithreaded console program package. I would like to check it's peak memory usage. When I check the cmd windows process in task manager I allayes get something like 6 or 7 Mb, but I...
8
by: TheB | last post by:
Ok, lets try this again. I have a program which searches all disk drives for certain file types. When it finds a file it writes a record to a Firebird DB. The program normally is using 40 - 44...
21
by: matvdl | last post by:
I have a system that was originally developed in asp - the pages are saved in SQL (there are over 10,000 pages) and saved to a temp directory in the server when requested by a client. I have...
2
by: prathamesh.deshpande | last post by:
Hi All, I have a program written in VC++. I want to calculate the memory consumed by each of the individual functions within the program. So can anyone suggest how this could be done? I need to...
2
by: thomasolsen | last post by:
Hi, I have a java program running on Linux Debian using jre 1.6 (I have tried under 1.5 with excatly the same results). As the program is running as a service I have been watching the memory usage...
3
by: crazy420fingers | last post by:
I'm running a python program that simulates a wireless network protocol for a certain number of "frames" (measure of time). I've observed the following: 1. The memory consumption of the program...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.