Integrated malloc debugging

Submitted by Robert Szeleney on Thu, 2006-01-19 15:01.

As every developer may know, making sure that all your runtime allocated memory is actually freed is not an easy task. For *nix there are tools like dmalloc, etc. which make is possible to dump a list of not freed memory when your application terminates. Although dmalloc works fine, integrating it into your application may be very difficult, depending on the size and complexity of your application. Furthermore, "memory debugging" shared libraries for which you don't have the source will be "somewhat" difficult. The same goes for applications where you don't have the source.

SkyOS has such a "memory debugging" support intergrated. If you run SkyOS in debug mode and press CTRL+ALT+SHIFT while your application starts, the internal memory debugger gets activated. Once your application terminates you will get a list of all not freed memory regardless when/where and from whom it was allocated. All memory allocations from the application itself and from implicit as well as explicit linked libraries will be recorded.

To sum it up, when your application terminates you will get something like this:


Memory statistics:
Not freed memory:
23: 156338: 23/desktop.app: 8400 times, 104 byte
23: 156343: 23/desktop.app: 2: /boot/system/dll/libsky.dll + 0x000086CA malloc@0 + 0x0000001A
23: 156353: 23/desktop.app: 3: /boot/system/dll/libskygi.dll + 0x00027CEC GI_FontSet@0 + 0x0000005C
23: 156363: 23/desktop.app: 4: /boot/system/dll/libskygi.dll + 0x00027D21 GI_FontDuplicate@0 + 0x00000011
23: 156375: 23/desktop.app: 5: /boot/system/dll/libskygi.dll + 0x00027B49 GI_FontSystemGet@0 + 0x00000069
23: 156386: 23/desktop.app: 6: /boot/system/dll/libskygi.dll + 0x00027F05 GI_FontGetDefault@0 + 0x00000015
23: 156399: 23/desktop.app: 7: /boot/system/desktop/desktop.app + 0x0000210A main
23: 156408: 23/desktop.app: 8:
23: 156435: 23/desktop.app: 8 times, 400 byte
23: 156442: 23/desktop.app: 2: /boot/system/dll/libsky.dll + 0x000086CA malloc@0 + 0x0000001A
23: 156452: 23/desktop.app: 3: /boot/system/dll/libskygi.dll + 0x0000F8D2 GI_MenuItemCreate@0 + 0x00000022
23: 156463: 23/desktop.app: 4: /boot/system/desktop/desktop.app + 0x000006A7 desktop_create_mount_fs_menu@0 + 0x00000147
23: 156475: 23/desktop.app: 5: /boot/system/desktop/desktop.app + 0x00000820 desktop_create_mount_menu@0 + 0x00000150
23: 156487: 23/desktop.app: 6: /boot/system/desktop/desktop.app + 0x00001A22 win_func@0 + 0x000005F2
23: 156499: 23/desktop.app: 7: /boot/system/dll/libskygi.dll + 0x0000A989 GI_dispatch_message_direct_internal@0 + 0x00000059
23: 156512: 23/desktop.app: 8: /boot/system/dll/libskygi.dll + 0x00007E59 GI_MessageDispatch@0 + 0x00000039
23: 156523: 23/desktop.app: 9: /boot/system/desktop/desktop.app + 0x000013DC main@0 + 0x0000023C



SgtrQH

JXBLApH SgtrQH

ahwFynwh

mJkGYNHy ahwFynwh

Interesting

That's nice, I should check my libtimer and weather service for leaks...