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

Memory Leak detection

Hi all,

I am new to c++. I have written one c++ application. I want to detect
memory leaks from my program.

I tried with following code which i got from net.
if(_CrtDumpMemoryLeaks() == TRUE) // reports no leak

{
printf("detected 1");
}
int *foo = new int[4];

if(_CrtDumpMemoryLeaks() == TRUE)//reports a memory leak

{
printf("detected 2");
}
delete[] foo;
foo = NULL;
if(_CrtDumpMemoryLeaks() == TRUE)// reports no leak

{
printf("detected 3");
}

Ideally first time i should not get any memory leak. But when i run
above code all print statements are executed.

Can anyone tell me why this is happening?

Please correct me if i am wrong.

thanks in advance.
Feb 4 '08 #1
1 1767
Archana wrote:
Hi all,

I am new to c++. I have written one c++ application. I want to detect
memory leaks from my program.

I tried with following code which i got from net.
if(_CrtDumpMemoryLeaks() == TRUE) // reports no leak
<snip>
>

Ideally first time i should not get any memory leak. But when i run
above code all print statements are executed.

Can anyone tell me why this is happening?
Who knows? We don't know what _CrtDumpMemoryLeaks() does. If it is a
platform specific utility, ask on a group for that platform

--
Ian Collins.
Feb 4 '08 #2

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

Similar topics

5
by: blugus | last post by:
Hi Guys, I've been try to use Dinkum STL library. It workes well first, but report memory leak in MFC Debug Mode. I use Dinkum Unabridged Library for VC++ V4.02, MSVC6, WIN2000 SERVER. I...
8
by: __jakal__ | last post by:
Hello, Is there any good memory leak detection software for C++ available as a freeware... I had used purify but had to discontinue due to huge license fees... Also tried Sun workshop memory...
6
by: Scott Niu | last post by:
Hi, I have this following simple c++ program, it will produce memory leak ( see what I did below ). My observation also showed that: There will be a mem leak when all the 3 conditions are true:...
7
by: mosaic | last post by:
Hi, all I really interested in how to check the memory leak of a program. Your smart guys, do you have excellent ideas that could share with me? Thank you. The following is my idea: In C...
0
by: Frank Lopez | last post by:
Does anyone know if Microsoft generated a whitepaper on this topic? Does anyone know what the solution is? (meaning, eliminate the leak problem -- I am seeing three memory leaks from...
4
by: mast2as | last post by:
Hi again I was still debugging some code and check for memory leaks with valgrind and found out that valgrind finds a leak when i use deque<Somethingaqueue ?! I am compiling under Linux for...
8
by: kk_oop | last post by:
Hi. Any recommendations for memory leak detection tools for C++ running on Linux or Solaris? I'm interested in static (compile time) and runtime detection. It's for a large project. Thanks! ...
1
by: dh | last post by:
Will GC.GetTotalMemory(true) reliably tell if a console app could have a memory leak, given the nature of memory management of GC in .NET? Like calling it two times, each at the beginning and right...
16
by: graham.keellings | last post by:
hi, I'm looking for an open source memory pool. It's for use on an embedded system, if that makes any difference. Something with garbage collection/defragmentation would be nice. It should have...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.