Thread: Memory Management Apps

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    47

    Memory Management Apps

    I know insure++ is the holy grail of applications, but Im guessing it's only available via a commercial license?

    I use gnu profiler and a DDD a visual debugger, I was hoping to have an application for checking memory (leaks, reallocation, etc.) Any suggestions? How is valgrind? Is there a graphical front end?

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Valgrind is pretty popular. I think there is a GUI front end for it, try google.

    One problem with valgrind that rendered it a waste of time for me is that it includes anything not freed at close as leaked. If you have a variable that is in use right up until the end, you don't have to free it, the OS will, so this is kind of stupid.*

    Of course, it is easy enough to just free everything anyway, as a matter of form and/or to satisfy valgrind. Unfortunately, there are a number of very significant API's that are not written to satisfy valgrind, such as gtk+, and apparently valgrind was not written to work with them either -- it has so many "leaks" to trace in this instance it is useless to try finding a real one.

    Which I don't need a mem checker for hello world -- the first time I needed one was with a big gtk app. At first I was horrified, then I googled around and found out it is a "known issue" although there is no intention to correct it. Perhaps this is intrinsic to the way any mem checker must work.

    But don't let my opinion stop you -- several of the seasoned pro regulars around here have spoken highly of it.

    *nb that is the explanation of the gtk issue as I remember it, at least
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I've always felt that not freeing what you allocate is poor practice.


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    gtk+ is an API?

    Window API's that leak memory?

    Can you be more specific?

  5. #5
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by quzah View Post
    I've always felt that not freeing what you allocate is poor practice.
    Totally agree. Of course, in that case there is no need for a mem checker.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  6. #6
    Registered User
    Join Date
    Dec 2009
    Posts
    47
    I am going to give it a try. I have a bit of a unique situation, the code is for myself mainly but if others were to use it I have code that can be switched on at compile time to manage memory (which is hidden from the caller by my functions etc...) that they may not even know they are innitializing in the first place. I noticed the overhead is significant though, with memory management switched on it takes the same program twice as long.....it is unfortunate. But this is only in an extreme testing case to evaluate it and the actual cases the code will run it shouldn't be an issue. The reason memory management is an option is the nature of the program, main.c is called hundreds of thousands of times but only executes for a short amount of time, conditional loops inside main could result in more memory allocation but reasignment of pointers (without freeing), so others using my code may be unaware of this which is why I made a switch for automatic memory management to clean things up....i'm thinking I can fine tune it to speed it up but maybe not....anyways that's why I need a memory checker, to make sure i'm tidying up properly. The biggest issue i'm having is modular coding and creating new pointers within a scope of a function, all this memory and pointers I just need to make sure i'm doing it properly.

  7. #7
    Registered User
    Join Date
    Dec 2009
    Posts
    47
    Grabbed valigard and a gui front-end and it is very good, useful, and not too difficult to get up and running. Really helped me see where potential problems were and helped me quickly resolve them. Nice tool to have at home.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with insert/delete binary search tree
    By Nazgulled in forum C Programming
    Replies: 39
    Last Post: 03-25-2009, 04:24 PM
  2. Memory Management
    By black_spot1984 in forum C++ Programming
    Replies: 9
    Last Post: 10-08-2008, 11:25 AM
  3. Shared memory between Apps
    By Mastadex in forum Windows Programming
    Replies: 6
    Last Post: 05-11-2006, 03:09 PM
  4. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  5. Managing shared memory lookups
    By clancyPC in forum Linux Programming
    Replies: 0
    Last Post: 10-08-2003, 04:44 AM