Thread: Troubleshooting strange memory problem

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    3

    Troubleshooting strange memory problem

    When I run my (GDI-based, mix of C and C++) graphics application for 10-15 minutes, the OS starts having strange behavior like saying "out of memory" when I try to run anything (including task manager) and also there are strange graphics artifacts on the display (I am using RDP to access the machine).

    Its clear there is some sort of memory/resource leak, but I have tried looking at Heap for my process in WindDBG and UMDH and do not see anything growing abnormally. I am allocating memory with GlobalAlloc and GlobalFree.

    I am also doing alot of creation, manipulation (bitblt) and destruction of bitmaps, so I thought that maybe I was not freeing my bitmaps or some other GDI object, but the GDI handles in Task Manager (and everything else) aren't going up.

    There is apparently some sort of 'special' resource being allocated that I cannot see on taskmanager or windbg, but I can't seem to figure out what it is.

    I know without seeing my program it will be difficult to troubleshoot in detail, but I am looking for general suggestions what sort of resource might be being eaten up.

    Thanks!
    Last edited by locksleyu; 03-31-2010 at 02:42 PM.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    You may wish to look into programs that can track memory leaks, such as valgrind for Linux. There are similar applications. I don't know the names of any specific tool, but it's a start.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Dec 2008
    Posts
    3
    Elysia, Thanks for the response. I looked around and Rational Purify seemed the most promising, but it doesnt support my OS (64-bit Windows 7). Does anyone know any tool that is supported by that OS and might help? Preferrably, I don't want to have to re-compile my app.

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Does this help?
    Alternatively, there is a free memory leak detector here, but it requires a recompile.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mutex and Shared Memory Segment Questions.
    By MadDog in forum Linux Programming
    Replies: 14
    Last Post: 06-20-2010, 04:04 AM
  2. Replies: 10
    Last Post: 09-22-2009, 11:38 AM
  3. Memory problem - malloc, pointers and vector
    By DrSnuggles in forum C++ Programming
    Replies: 18
    Last Post: 08-14-2009, 10:28 AM
  4. Memory Problem with _beginthread()
    By nord in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 11:44 AM
  5. Problems with shared memory shmdt() shmctl()
    By Jcarroll in forum C Programming
    Replies: 1
    Last Post: 03-17-2009, 10:48 PM