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

searching a function of standard libraries to help detecting memory leaks

Hi all! I am doing a crude investigation of memory leaks in objects
created by external libraries.
Since I don't have access to the source code, I can't tell if an object
are freeing its resources properly during destruction.

For now, I need a portable function that can tell me the available free
store memory. With that, I can do things like:

size_t mem = getFreeStoreAvailable();
{
SuspiciousObject obj;
...
} // obj destructor invoked here by compiler

assert( mem == getFreeStoreAvailable() );
of course it won't work for detecting resource leaks (e.g: handles)

do you know this function? any ideas?

Diego Martins
HP

Oct 5 '06 #1
4 1644
Diego Martins wrote:
Hi all! I am doing a crude investigation of memory leaks in objects
created by external libraries.
Welcome to the club!
Since I don't have access to the source code, I can't tell if an
object are freeing its resources properly during destruction.

For now, I need a portable function that can tell me the available
free store memory.
There is no such standard function. You either need to write your own,
or use whatever mechanism your OS provides.
With that, I can do things like:

size_t mem = getFreeStoreAvailable();
{
SuspiciousObject obj;
...
} // obj destructor invoked here by compiler

assert( mem == getFreeStoreAvailable() );
of course it won't work for detecting resource leaks (e.g: handles)
No such thing[s] in standard C++.
>
do you know this function? any ideas?
No such standard function. Try the newsgroup for your OS.

Generally speaking, you _could_ measure it by allocating [in a loop]
different amounts until you get a failure, followed by freeing all that
you just allocated. However, that is not necessarily the true measure
of the "available free store memory". Remember the "you change it if
you measure it" principle? Ultimately, even if you have to call some
function to measure the free store memory, you *could* change it, and
the behaviour of the program *might* be different from if you didn't
ask for the avaiable free store memory.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Oct 5 '06 #2
Diego Martins wrote:
Hi all! I am doing a crude investigation of memory leaks in objects
created by external libraries.
Since I don't have access to the source code, I can't tell if an object
are freeing its resources properly during destruction.

For now, I need a portable function that can tell me the available free
store memory. With that, I can do things like:

size_t mem = getFreeStoreAvailable();
{
SuspiciousObject obj;
...
} // obj destructor invoked here by compiler

assert( mem == getFreeStoreAvailable() );
of course it won't work for detecting resource leaks (e.g: handles)

do you know this function? any ideas?
<OT>
If you are working on a x86 I suggest using valgrind.
It will detect memory leaks without the need to recompile
(although you may wish to recompile with -g to obtain
line-number information).
</OT>

HTH,
- J.
Oct 6 '06 #3
You might want to try Rational Purify. You can download it and try it
for 15 days
http://www-306.ibm.com/software/awdtools/purify/

I do not work there ..Ok, I just used the tool, and it helped me to
find memory leak.

Good luck

Osama Aouda

Diego Martins wrote:
Hi all! I am doing a crude investigation of memory leaks in objects
created by external libraries.
Since I don't have access to the source code, I can't tell if an object
are freeing its resources properly during destruction.

For now, I need a portable function that can tell me the available free
store memory. With that, I can do things like:

size_t mem = getFreeStoreAvailable();
{
SuspiciousObject obj;
...
} // obj destructor invoked here by compiler

assert( mem == getFreeStoreAvailable() );
of course it won't work for detecting resource leaks (e.g: handles)

do you know this function? any ideas?

Diego Martins
HP
Oct 7 '06 #4

Osama Aouda wrote:
You might want to try Rational Purify. You can download it and try it
for 15 days
http://www-306.ibm.com/software/awdtools/purify/

I do not work there ..Ok, I just used the tool, and it helped me to
find memory leak.

Good luck

Osama Aouda
thanks. I'll use VLD

it is a shame there is no portable way to achieve this :(

Oct 9 '06 #5

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

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
2
by: barkha shah | last post by:
Hi , Can any one please suggest me the memory Leak detecting tool in Visual Studio.Net 2003 Release version Framework. Can I use Numega Bounds checker for this. Thanks and Regards. barkha
31
by: bilbothebagginsbab5 AT freenet DOT de | last post by:
Hello, hello. So. I've read what I could find on google(groups) for this, also the faq of comp.lang.c. But still I do not understand why there is not standard method to "(...) query the...
2
by: ASP.Confused | last post by:
How would I go about detecting a memory leak? My web hosting provider has our site set up to only have a root "bin" folder for .NET apps, and I would like to be able to watch how much memory is...
28
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
4
by: Tony Lownds | last post by:
(Note: PEPs in the 3xxx number range are intended for Python 3000) PEP: 3107 Title: Function Annotations Version: $Revision: 53169 $ Last-Modified: $Date: 2006-12-27 20:59:16 -0800 (Wed, 27 Dec...
13
by: Ilias Lazaridis | last post by:
How to detect memory leaks of python programms, which run in an environment like this: * Suse Linux 9.3 * Apache * mod_python The problem occoured after some updates on the infrastructure....
2
by: Oltmans | last post by:
Hi all, I'm stuck in a situation where I need help. Any help will be highly appreciated. I've created an object, after creating the object, I'm assigning one of its functions to an event handler...
53
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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...
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.