coryshrmn / websitecatalog

0 stars 1 forks source link

memory leak #22

Closed coryshrmn closed 11 years ago

coryshrmn commented 11 years ago
==2527== Invalid free() / delete / delete[] / realloc()
==2527==    at 0x4C2A739: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==2527==    by 0x403894: main (WebsiteCatalog.c:267)
==2527==  Address 0x7ff000210 is on thread 1's stack
==2527== 
==2527== 
==2527== HEAP SUMMARY:
==2527==     in use at exit: 11 bytes in 1 blocks
==2527==   total heap usage: 220 allocs, 220 frees, 9,409 bytes allocated
==2527== 
==2527== 11 bytes in 1 blocks are definitely lost in loss record 1 of 1
==2527==    at 0x4C2B3F8: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==2527==    by 0x402EF0: main (WebsiteCatalog.c:44)
==2527== 
==2527== LEAK SUMMARY:
==2527==    definitely lost: 11 bytes in 1 blocks
==2527==    indirectly lost: 0 bytes in 0 blocks
==2527==      possibly lost: 0 bytes in 0 blocks
==2527==    still reachable: 0 bytes in 0 blocks
==2527==         suppressed: 0 bytes in 0 blocks
==2527== 
==2527== For counts of detected and suppressed errors, rerun with: -v
==2527== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 2 from 2)
coryshrmn commented 11 years ago

So this actually happens by just running the program at all. Not sure what changed.

I fixed the first part by removing:

free(fname);

...from main, but there is still the malloced fname which is leaked. I commented the malloc line in WebsiteCatalog.c

ghost commented 11 years ago

Could you test master branch d1d4f8a0b31339a3413ebedc61ac9cb91f524907 ? I don't see any memory leaks now.

coryshrmn commented 11 years ago

The fname memory leak seems to be fixed, however there is now a memory leak in promptInput.


==2290== HEAP SUMMARY:
==2290==     in use at exit: 11 bytes in 1 blocks
==2290==   total heap usage: 107 allocs, 106 frees, 6,427 bytes allocated
==2290== 
==2290== 11 bytes in 1 blocks are definitely lost in loss record 1 of 1
==2290==    at 0x4C2B3F8: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==2290==    by 0x403663: promptInput (WebsiteCatalog.c:118)
==2290==    by 0x40349D: InitDriver (WebsiteCatalog.c:47)
==2290==    by 0x40343E: main (WebsiteCatalog.c:20)
==2290== 
==2290== LEAK SUMMARY:
==2290==    definitely lost: 11 bytes in 1 blocks
==2290==    indirectly lost: 0 bytes in 0 blocks
==2290==      possibly lost: 0 bytes in 0 blocks
==2290==    still reachable: 0 bytes in 0 blocks
==2290==         suppressed: 0 bytes in 0 blocks

coryshrmn commented 11 years ago

By the way, that last comment is from a simple sample run:


Please enter the filename: top_25.txt
================================================
1 - Insert a Website
2 - Delete a Website by URL
3 - Search for a Website by URL
4 - Print hash buckets
5 - Print BST in order
6 - Print BST indented
7 - Print hash efficiency
8 - Save
9 - Save as...
10 - Quit
================================================
Enter your option (1-10): 10
>VERBOSE : Exiting program on user request

ghost commented 11 years ago

That should be normal. On Mar 25, 2013 6:51 AM, "coryshrmn" notifications@github.com wrote:

By the way, that last comment is from a simple sample run:

Please enter the filename: top_25.txt

1 - Insert a Website 2 - Delete a Website by URL 3 - Search for a Website by URL 4 - Print hash buckets 5 - Print BST in order 6 - Print BST indented 7 - Print hash efficiency 8 - Save 9 - Save as...

10 - Quit

Enter your option (1-10): 10

VERBOSE : Exiting program on user request

— Reply to this email directly or view it on GitHubhttps://github.com/coryshrmn/websitecatalog/issues/22#issuecomment-15394036 .

coryshrmn commented 11 years ago

The output is normal, but there is a memory leak.


11 bytes in 1 blocks are definitely lost in loss record 1 of 1
   at 0x4C2B3F8: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x403663: promptInput (WebsiteCatalog.c:118)
   by 0x40349D: InitDriver (WebsiteCatalog.c:47)
   by 0x40343E: main (WebsiteCatalog.c:20)

ghost commented 11 years ago

I couldn't find the memory leaks with latest master branch of the following commit: 51e33464e8cfa428cb1018989be6a4df21317060.

If problem persists on your valgrind, please show me during the class. We can trace them together.

See you soon!

coryshrmn commented 11 years ago

We fixed this in class today.