Solved

Numega  and memory leak

Posted on 2002-04-10
8
454 Views
Last Modified: 2013-12-14
Hello,
I'm using Numega(bound checker) with VC++ 6.0.
I'm writing a basic program : historical "foo()" function
that doing nothing, and I see 4 memory leaks:

   memory leak-Operator _new in locale0.cpp (55) : 40 bytes
   memory leak-Operator _new in .\xmemory (30): 33 bytes
   memory leak-_Malloc_dbg in onexit.c(251): 176 bytes
   Resource Leak:Initialize criticalSection in xlock.cpp(50)
 Expert,Can you help me to understand this phenomena?
 Thanks by advance.
NathalieB.

 
 
0
Comment
Question by:NathalieB
  • 4
  • 3
8 Comments
 
LVL 10

Expert Comment

by:makerp
Comment Utility
lets see yoru sauce code
0
 

Author Comment

by:NathalieB
Comment Utility
#pragma warning(disable:4786)
#include <map>
using namespace std;

class CMapTest
{
public:
     typedef map<long,int> TTransMap;

     CMapTest();
     
     ~CMapTest();
     
     void InsertLong(const long lvalue,int lResult );
private:

     TTransMap m_mapTransceiver;
     
};


CMapTest::CMapTest()
{}


CMapTest::~CMapTest()
{
     m_mapTransceiver.clear();
}


void CMapTest::InsertLong(const long lvalue,int lResult )
{
     pair<TTransMap::iterator,bool> a = m_mapTransceiver.insert(make_pair(lvalue,lResult));
}

void main()
{

     CMapTest toto;
     toto.InsertLong(3,1);
}
0
 
LVL 10

Accepted Solution

by:
makerp earned 50 total points
Comment Utility
you have nothing allocated outside of main so it aint that. it looks to me like these are allocations in the STL, therefore i would not worry. you will have to hack your implementation of the stl to fix them, something i would not suggest
0
 

Author Comment

by:NathalieB
Comment Utility
Hello,
I'm using STlport4.0 ang a big consumer of these containers.
So Do you know which files it's concerned and if existing an updating version that solve the problems?
 
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 10

Expert Comment

by:makerp
Comment Utility
does the number of leaks increase with the more code you create or does it stay constant, if it stays constant then ignore it
0
 
LVL 1

Expert Comment

by:Mensana
Comment Utility

Hi Nathalie,

I ran your code in VC++ 6.0, in debug mode and there were no memory leaks reported. Not that I want to praise what big MS does, but from my painful experiences with Numega's BoundsChecker, I'd rather rely on what Microsoft reports this time.
In fact your code is so simple that you don't need BoundsChecker to see whether memory leaks exist or not.
To convince yourself, replace one of the map's types with a more complex type that has a destructor and than trace inside it. You'll notice that the destructor is called when you call map::clear.

Regards,
Eddie
0
 
LVL 10

Expert Comment

by:makerp
Comment Utility
i use

#include <crtdbg.h>

void main()
{
  _CrtSetReportMode(_CRT_WARN,_CRTDBG_MODE_FILE);
  _CrtSetReportFile(_CRT_WARN,_CRTDBG_FILE_STDOUT);

  /* blah blah */

  _CrtDumpMemoryLeaks();
}
0
 

Author Comment

by:NathalieB
Comment Utility
Hello makerp,

I receive the respons from Numega Support:
http://nashua.compuware.com/support/knowledgebase/docs/344.htm
Thank you.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
maze travler 6 47
C++ Language error 28 144
Delphi : could not find program, '...exe' 2 115
FMX TCameraComponent Problem 2 10
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now