Memory leaks!

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2007
Posts: 390
Reputation: skatamatic will become famous soon enough skatamatic will become famous soon enough 
Solved Threads: 39
skatamatic skatamatic is offline Offline
Posting Whiz

Memory leaks!

 
0
  #1
Aug 26th, 2008
I don't know what's going on here...but I always seem to get 2 leaks of 40bytes each consisting of FF FF FF FF.... Even with all the code commented out, I still seem to get these leaks. I'm running Visual Studio on Vista SP1, so perhaps a combatibility issue? Or maybe I'm just forgetting my DMA from the years class. Here's the code:

  1. #include <iostream>
  2. using namespace std;
  3. #include "funcs.h"
  4. // Turning on the heap checker
  5.  
  6. bool HashMake(int *&iHash, int iSize)
  7. {
  8. bool bReturn = true;
  9. if (iSize >= 1)
  10. {
  11. HashFree(iHash, iSize);
  12. iHash = new (nothrow) int[iSize];
  13. for (int i = 0; i < iSize; i++)
  14. iHash[i] = -1;
  15. }
  16. else
  17. bReturn = false;
  18.  
  19. return bReturn;
  20. }
  21.  
  22. void HashFree(int *&iHash, int iSize)
  23. {
  24. delete [] iHash;
  25. iHash = 0;
  26. return;
  27. }
  28.  
  29. void TestCode()
  30. {
  31. _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
  32. /*int const SIZE = 10;
  33. int * iHash(NULL);
  34. HashMake(iHash, SIZE);
  35. for (int i = 0; i < SIZE; i++)
  36. cout << iHash[i] << endl; */
  37. cin.get();
  38. // HashFree(iHash, SIZE);
  39. }

all that is called in main.cpp is the testcode() function. I commented out any time dma is used (in testcode() ) and the stupid memory leaks still show up. I'm getting frustrated!! Any help would be appreciated!
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 390
Reputation: skatamatic will become famous soon enough skatamatic will become famous soon enough 
Solved Threads: 39
skatamatic skatamatic is offline Offline
Posting Whiz

Re: Memory leaks!

 
0
  #2
Aug 26th, 2008
Hmmm ok update. The leaks are being found before I even start the program, like just as I hit F5 to build it they appear. If I purposely break the code and get rid of the deletes, all 10 of the leaks append to the 2 leaks. What could cause this
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC