473,396 Members | 1,936 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,396 software developers and data experts.

tracking memory allocations by class

Hi,

I was wondering if there is an easy way to keep track of all allocations
issued by instances of a specific class and its subclasses (i.e. keep track
of memory consumption of the class instances, including e.g. heap-allocated
member variables).

A global overloading of new / delete operators is out of question, because
I have to track memory consumption for a specific class, and also because
the base class implementation will be dynamically linked.

I had no luck overriding the member operator new either, because while it
is called to allocate the class instance itself, allocations within the
instance cannot be tracked that way. Maybe via a friend declaration?

Ideally, this should work as transparently as possible, i.e. no placement
operator new or other syntax differences.

Thanks for your input!

Manuel

Jul 22 '05 #1
1 2075
Manuel Massing <pl*********@spam.de> wrote in message news:<cd*************@news.t-online.com>...
Hi,

I was wondering if there is an easy way to keep track of all allocations
issued by instances of a specific class and its subclasses (i.e. keep track
of memory consumption of the class instances, including e.g. heap-allocated
member variables).

A global overloading of new / delete operators is out of question, because
I have to track memory consumption for a specific class, and also because
the base class implementation will be dynamically linked.

I had no luck overriding the member operator new either, because while it
is called to allocate the class instance itself, allocations within the
instance cannot be tracked that way. Maybe via a friend declaration?


No, not possible, and I think the question isn't even sensible.
What exactly is the set of allocations, anyway? How about memory
allocated by factory methods? The factory may have used a cache, or
a memory pool. If the first allocation caused the factory to
new[] a pool of 100 objects, and the next 99 allocatons just
used that pool, do you assign the memory all to the first factory
user? What about std::cout? It may allocate a buffer when first
used, and resize it dynamically when large strings are printed.
How are you going to track that?

Regards,
Michiel Salters
Jul 22 '05 #2

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

Similar topics

4
by: Moosebumps | last post by:
When I have time, I am planning to evaluate Python for console game development (on Playstation 2, GameCube, and Xbox). Does anyone have any experience with this? Pretty much the only resource...
10
by: Jakob Bieling | last post by:
Hi, Whenever allocating memory using operator new or operator new I feel like I should only use it very sparingly, because otherwise memory is wasted (by additional overhead needed to manage all...
8
by: Tron Thomas | last post by:
As part of applying for a programming position at a company, I recently I had submitted some code samples to one of the developers for review. This is the feedback I received: One of his...
18
by: Tron Thomas | last post by:
Given the following information about memory management in C++: ----- The c-runtime dynamic memory manager (and most other commercial memory managers) has issues with fragmentation similar to a...
3
by: =?Utf-8?B?R3JhaGFt?= | last post by:
I've added 2 tracking services to the wf runtime; one is the standard SqlTrackingService: trackingService = new SqlTrackingService(<trackingConnectionString>); <workflow...
5
by: Andreas Schmitt | last post by:
Hi, I recently worked on an open source project and tried to make on of the arrays they are using dynamically allocated to get rid of the max size. I used the realloc instead of the usual C++...
27
by: George2 | last post by:
Hello everyone, Should I delete memory pointed by pointer a if there is bad_alloc when allocating memory in memory pointed by pointer b? I am not sure whether there will be memory leak if I do...
3
by: not_a_commie | last post by:
The CLR won't garbage collect until it needs to. You should see the memory usage climb for some time before stabilizing. Can you change your declaration to use the 'out' keyword rather than a 'ref'...
9
by: Steven Powers | last post by:
Imagine the following setup class Parent { virtual void doStuff(); } class Child : public Parent { virtual void doStuff(); }
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.