memory leak detection

Discussion in 'Wii - Hardware, Devices and Utilities' started by dj_skual, Apr 17, 2016.

  1. dj_skual
    OP

    dj_skual Code & Mix

    Member
    950
    233
    Mar 9, 2008
    France
    hello,

    i'm looking about a program that can read my sources or my elf file and can report to me all memory leak in my program... i know that exist, but can't remember...

    thx
     
  2. GreyWolf

    GreyWolf GBAtemp Psycho!

    Member
    4,184
    809
    Mar 2, 2015
    United States
    I've never heard of a program that can do that. You have to look at the source and make sure you're freeing everything you allocate manually. A robust debugger might be able to detect that somewhat but there is only USB Gecko for the Wii/GC.
     
  3. dj_skual
    OP

    dj_skual Code & Mix

    Member
    950
    233
    Mar 9, 2008
    France
    i already used an app like this on another pc... but can't remember the name... think @giantpune gave me the name... but not sure
     
  4. GreyWolf

    GreyWolf GBAtemp Psycho!

    Member
    4,184
    809
    Mar 2, 2015
    United States
    It's a lot different on a PC. A debugger can easily tell how much memory there is before a program runs and how much is left afterwards. The Wii doesn't have an operating system so all memory allocation and freeing is up to the app that's running.
     
  5. dj_skual
    OP

    dj_skual Code & Mix

    Member
    950
    233
    Mar 9, 2008
    France
    no i mean an pc app wich read my wii app sources and tell me where i was wrong with memory
     
  6. GreyWolf

    GreyWolf GBAtemp Psycho!

    Member
    4,184
    809
    Mar 2, 2015
    United States
    An application can't do that except maybe to tell you that you're missing a call to free() or a delete keyword. It's easy to determine whether your code is leaking memory on Windows because you can stop it and inspect everything. You can do that minimally with a USB Gecko on the Wii but with just devkitPro not so much.

    The best thing is to start by searching for "new" and "delete" and make sure everything you instantiate is destroyed at some point. Same with malloc/free. If you have to ask for the memory you should be giving it back. :P
     
  7. Coto

    Coto GBAtemp Addict

    Member
    2,379
    419
    Jun 4, 2010
    Chile
    Well, imho the best "non user friendly" memory leak detector is the exception handler where the processor halts the process currently executed due to some of the following exception cases:

    undefined area access / map does not exist on target hardware

    data abort / protected area access and the region permissions do not match / classic kernel map reads from usermode exception or your own exception triggered because you set the MMU properties to protect that area

    bios call : the software interrupt operation used by high level OSses to force the CPU to execute asap an embedded call

    so if we compare the software debugger found on several IDEs against the ones found in the hardware, they're not user friendly

    cheers