473,554 Members | 2,829 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2086
Manuel Massing <pl*********@sp am.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
2707
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 I have found, and the only thing that makes me think it might be possible is this: http://asbahr.com/python.html I would be interested to hear...
10
1842
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 those allocations) which also loses some performance. I am specifically talking about many little allocations (approx. 16-512 bytes). Is my feeling...
8
6799
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 concerns was frequent calls to new and delete, which can cause memory fragmentation over time. An example is the allocation and destruction
18
6657
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 hard drive file system. Over time, the more often use call new/delete or alloc/free, there will be gaps and fragments in the heap. This can lead...
3
2508
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 Runtime>.AddService(trackingService); trackingService.IsTransactional = false; trackingService.UseDefaultProfile = true; This works just fine.
5
6186
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++ new and delete because they asked me to stick to their "coding style" Well whatever..
27
2930
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 not delete a. try { a = new int ;
3
3216
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' keyword?
9
2626
by: Steven Powers | last post by:
Imagine the following setup class Parent { virtual void doStuff(); } class Child : public Parent { virtual void doStuff(); }
0
7497
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8010
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7530
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7862
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6119
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5414
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5136
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3539
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1994
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.