Running program with valgrind

Everything else that doesn't fall into one of the other PB categories.
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Running program with valgrind

Post by StarBootics »

Hello everyone,

My question today is about running a program compiled with PureBasic with valgrind to check if the program as memory leaks among other problems.
==25059== HEAP SUMMARY:
==25059== in use at exit: 4,272,043 bytes in 58,826 blocks
==25059== total heap usage: 981,301 allocs, 922,475 frees, 227,836,882 bytes allocated
==25059==
==25059== LEAK SUMMARY:
==25059== definitely lost: 29,952 bytes in 37 blocks
==25059== indirectly lost: 72,089 bytes in 2,958 blocks
==25059== possibly lost: 5,615 bytes in 54 blocks
==25059== still reachable: 3,929,187 bytes in 53,674 blocks
==25059== of which reachable via heuristic:
==25059== length64 : 6,104 bytes in 18 blocks
==25059== suppressed: 0 bytes in 0 blocks
==25059== Rerun with --leak-check=full to see details of leaked memory
==25059==
==25059== For lists of detected and suppressed errors, rerun with: -s
==25059== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Apparently I have some memory leaks somewhere in the program but I don't know how to find and correct them. When run valgrind with --leak-check=full I got many leaks coming from the external libraries I'm using, for example :
==25220== at 0x484582F: realloc (vg_replace_malloc.c:1437)
==25220== by 0x5ABF4D8: ??? (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.12.0)
==25220== by 0x5ABFC60: ??? (in /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.12.0)
==25220== by 0x52B0523: ??? (in /usr/lib/x86_64-linux-gnu/libcairo.so.2.11600.0)
==25220== by 0x5182A48: ??? (in /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0.5000.12)
==25220== by 0x5A90EFD: ??? (in /usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0.5000.12)
==25220== by 0x51AA802: ??? (in /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0.5000.12)
==25220== by 0x51BA83D: ??? (in /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0.5000.12)
==25220== by 0x51BCEFD: ??? (in /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0.5000.12)
==25220== by 0x4B467A3: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.2406.32)
==25220== by 0x4A7D5E0: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.2406.32)
==25220== by 0x4A82177: ??? (in /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.2406.32)
Is this kind of problems I should worry about ?

Thanks in advance.
StarBootics
The Stone Age did not end due to a shortage of stones !
User avatar
mk-soft
Always Here
Always Here
Posts: 6244
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Running program with valgrind

Post by mk-soft »

Without Linux code we can't say much.
Do you use the GTK API? If so, you have to make sure that you release the results correctly.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Fred
Administrator
Administrator
Posts: 18219
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Running program with valgrind

Post by Fred »

Be sure to compile with the '-ds' flag to have the debug symbols in your final exe
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: Running program with valgrind

Post by StarBootics »

mk-soft wrote: Thu Mar 14, 2024 9:20 am Without Linux code we can't say much.
Do you use the GTK API? If so, you have to make sure that you release the results correctly.
Yes, I'm using GTK API and I'm also using cairo, pango and pangocairo API to create a custom widget that work like Trello board with cards. I will review the code one more time but the example of code are not very concise about how to work with them. One thing I can do is to upload the entire source code of the program (under 9 800 lines) or I can make a simplified version of the program but this will take some time.
Fred wrote: Thu Mar 14, 2024 10:13 am Be sure to compile with the '-ds' flag to have the debug symbols in your final exe
It would be nice if we can set compiler flags via the compiler option window instead of compiling via the command line terminal, I will give it a try.

Thanks again.
StarBootics
The Stone Age did not end due to a shortage of stones !
User avatar
mk-soft
Always Here
Always Here
Posts: 6244
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Running program with valgrind

Post by mk-soft »

GTK

- g_value_unset
-g_error_free
- g_list_free
- g_object_unref

If not const gchar
- g_free

and more ...
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply