Skip to content

Conversation

@bangarumahesh22
Copy link

This PR fixes a memory leak in the test.c example. Previously, an array allocated with malloc was not freed, causing 20 bytes of memory to remain allocated when the program exited.

Changes made:

Freed the allocated memory (ptr) before program exit to prevent the leak.

Verified using Dr. Memory that no memory leaks remain.

Verification:

Run ../build/bin/drmemory -- ./test to confirm no leaks reported.

Test compiled and ran successfully with gcc -g test.c -o test.

Impact:

This ensures proper memory management in the example code and prevents unnecessary memory leaks for users running the example.

@@ -0,0 +1,10 @@
#include <stdlib.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for reaching out to contribute.

This PR fixes a memory leak in the test.c example. Previously, an array allocated with malloc was not freed, causing 20 bytes of memory to remain allocated when the program exited.

I'm not sure I understand: which "test.c example" are you referring to? Could you supply the full path? And your PR seems to be adding a brand new directory examples/, rather than editing an existing file?

@bangarumahesh22
Copy link
Author

Hi @maintainers 👋

I’ve submitted this small fix for a memory leak in the test example.
The change frees the previously unfreed memory and has been verified using Dr. Memory.

Just checking in — please let me know if any updates or adjustments are needed.
Thank you for reviewing!

@derekbruening
Copy link
Contributor

Hi @maintainers 👋

I’ve submitted this small fix for a memory leak in the test example. The change frees the previously unfreed memory and has been verified using Dr. Memory.

Just checking in — please let me know if any updates or adjustments are needed. Thank you for reviewing!

Please see my question at #2567 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants