memory leaks

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • memory leaks

      Hey all,
      Source Code v2.3 is giving me memory leaks. This is what I get when I start an instance of TeapotWars . I have not read anything on this site about this. Am I missing something? I have both boost_1_36_0 and OggVorbis-win32sdk-1.0

      Detected memory leaks!
      Dumping objects ->
      {77} normal block at 0x00DA1AF0, 52 bytes long.
      Data: < > F0 1A DA 00 F0 1A DA 00 F0 1A DA 00 CD CD CD CD
      c:\users\wawa\!goodstuff\gamedevelopment\projects\gamecode v2.3\source\resourcecache\rescache2.cpp(56) : {76} normal block at 0x00DA1A80, 48 bytes long.
      Data: < Fl > B0 46 6C 00 00 00 00 00 CD CD CD CD CD CD CD CD
      {75} normal block at 0x00DA1A10, 52 bytes long.
      Data: < > 10 1A DA 00 10 1A DA 00 10 1A DA 00 CD CD CD CD
      {74} normal block at 0x00DA19C8, 12 bytes long.
      Data: < > C8 19 DA 00 C8 19 DA 00 CD CD CD CD
      {73} normal block at 0x00DA7F70, 48 bytes long.
      Data: <d a t a \ G a m > 64 00 61 00 74 00 61 00 5C 00 47 00 61 00 6D 00
      c:\users\wawa\!goodstuff\gamedevelopment\projects\gamecode v2.3\source\gamecode.cpp(241) : {72} normal block at 0x00DA7F08, 40 bytes long.
      Data: < k > B4 EE 6B 00 80 1A DA 00 00 00 00 00 CD CD CD CD
      c:\users\wawa\!goodstuff\gamedevelopment\projects\gamecode v2.3\source\gamecode.cpp(241) : {71} normal block at 0x00DA7E88, 68 bytes long.
      Data: < Fl > C8 46 6C 00 00 00 00 00 CD CD CD CD CD CD CD CD
      {70} normal block at 0x00DA7E38, 16 bytes long.
      Data: <8~ 8~ > 38 7E DA 00 38 7E DA 00 CD CD CD CD CD CD CD CD
      {69} normal block at 0x00DA7DE8, 16 bytes long.
      Data: < } } > E8 7D DA 00 E8 7D DA 00 CD CD CD CD CD CD CD CD
      {68} normal block at 0x00DA7D80, 44 bytes long.
      Data: < } } } > 80 7D DA 00 80 7D DA 00 80 7D DA 00 CD CD CD CD
      {67} normal block at 0x00DA7D28, 24 bytes long.
      Data: <(} (} (} > 28 7D DA 00 28 7D DA 00 28 7D DA 00 CD CD CD CD
      c:\users\wawa\!goodstuff\gamedevelopment\projects\gamecode v2.3\source\gamecode.cpp(211) : {66} normal block at 0x00DA7C78, 112 bytes long.
      Data: < bl > 8C 62 6C 00 00 00 00 00 CD CD CD CD CD CD CD CD
      c:\users\wawa\!goodstuff\gamedevelopment\projects\gamecode v2.3\source\gamecode.cpp(205) : {65} normal block at 0x00DA7C00, 60 bytes long.
      Data: < > 00 01 01 01 00 01 00 01 00 00 00 00 00 00 00 00
      Object dump complete.
      The program '[7684] TeapotWarsd.exe: Native' has exited with code 0 (0x0).

      The post was edited 1 time, last by Cosinet ().

    • GameCode overwrites the new operator, and uses GCC_NEW (or something to that effect).

      You should be able to double click the output feedback, ( rescache2.cpp(56), gamecode.cpp(211), etc.), and note the heap allocation occuring on that line.

      Now just do a check for where this memory is being de-alocated, put a break point, shut the game down, and see if it is getting hit. If not, check the surrounding logic.

      What build target are you running?

      B.
      -B.
    • I am runnning Windows Vista Home Premium, 2GB RAM, Intel Quad CPU @ 2.4GHz and using VS 2005.
      The heap allocation that fails is the GameCode.cpp statement m_ResCache = GCC_NEW ResCache(3, GCC_NEW ResourceZipFile(_T("\data\\GameCode2.zip")));

      As you said, the failure is on GCC_NEW ResourceZipFile and it seems odd to me but I certainly will appreciate any savvy suggestions/clarifications as to why this would fail.

      Right after the creation of m_ResCache object , the code below returns false which leads to the code exiting without releasing any object causing the runtime to scream about memory leaks.

      if (!m_ResCache->Init())
      {
      return false;
      }

      see attached for detailed info on the object creation at run time.

      Help is greatly appreciated. Thanks!
      Files
      • mpfile.jpg

        (87.26 kB, downloaded 1,148 times, last: )
    • Try and step into the new allocation, as it should fire off the ResCache's constructor.

      My first guess would be that the path being fed in is incorrect, or that the zip file it is looking for is not there either.

      Check to see if your solution/vcproj files are using the correct paths.
      -B.
    • I got a little dipper about where it fails and it's in ZipFile.cpp where it attempts to open it. I had moved the zip file out from the data subdirectory to its parent, the bin directory, foir this purpose of testing. The runtime is finding it but based on the values below, it seems it is only taking the first character of the string "G" instead of Gamecode2.zip

      Line 143,returns false statement, is executed. Could my mess have anything to do with ANSI/Unicode mappings?
      Files
      • resFileName.jpg

        (20.03 kB, downloaded 1,115 times, last: )
    • Cosinet

      Ok. That seems to be a problem with the char array being passed in, which screams Ansi/Unicode issues.

      Try using some different unicode (or multi-byte) strings, (wchar, tchar, std::string, const char*, etc.) for the path, depending on what your compiler/project settings are set to.

      Alternatively, add an additional method, something as follows:

      Source Code

      1. bool
      2. CZipFile::Init( const char* _pckResFileName )
      3. {
      4. // . . .
      5. }


      It will duplicate the logic, but if it works, then you can refactor, knowing it is something to do with Vista/Unicode/MByte.

      B.
      -B.

      The post was edited 1 time, last by jediboy ().

    • Thanks jediboy.
      The character set is unicode and all data types are what they're supposed to be. so we have no problem there.

      The real problem was that my "Working Directory" properties was blank! I set it to "..\..\Bin" . Duh!

      cheers.

      The post was edited 1 time, last by Cosinet ().

    • Jeez and that was causing a memory leak?

      Bleh....
      Mr.Mike
      Author, Programmer, Brewer, Patriot