Solved

Numega  and memory leak

Posted on 2002-04-10
8
472 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
ID: 6930990
lets see yoru sauce code
0
 

Author Comment

by:NathalieB
ID: 6931028
#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
ID: 6931044
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:NathalieB
ID: 6931152
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
 
LVL 10

Expert Comment

by:makerp
ID: 6931157
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
ID: 6931465

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
ID: 6931484
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
ID: 6934103
Hello makerp,

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

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

773 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