#21 Jul 4, 2009 1:53 am
Magician
GroupMembers
Posts147
JoinedJun 9, 2009
Holy smokes Batman!
Well, I think I MIGHT have fixed it, but I'm nothing close to sure.... I replaced all calls to str_dup with STRALLOC in boards.c and all calls to DISPOSE that were being used on pnote-> with STRFREE and I've been able to erase 9 messages straight with no problems. I've checked the log file for the instance that's running and there're no bug messages, so I'm hoping that what I did actually fixed the problem and didn't simply cover it up.
==24235== malloc/free: in use at exit: 3,330,261 bytes in 14,529 blocks. ==24235== malloc/free: 20,610 allocs, 6,082 frees, 4,638,689 bytes allocated. <--- yikes!
Well, I think I MIGHT have fixed it, but I'm nothing close to sure.... I replaced all calls to str_dup with STRALLOC in boards.c and all calls to DISPOSE that were being used on pnote->
#22 Jul 4, 2009 2:06 pm
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007
If Valgrind ran without complaining (except for memory leaks at the end, there) and you did everything you normally to do reproduce the problem, then you're probably in good shape. Valgrind is a very useful tool for debugging memory problems by the way, so it's good that you've gained some familiarity with it and already fixed nine problems.
As for fixing the memory leaks, you can turn on more debugging output to see where the memory leaks happened and where said memory was allocated. I think the flag is --leak-check=full or something like that (it tells you at the end what to put in). A lot of the "leaks" aren't actually problems, because they occur only when you quit the program without explicitly deleting things (which doesn't really matter in most cases because everything is freed on exit). You want to look for leaks that occur during normal execution of the program. For example, aborting a note might cause a memory leak if the various string pointers aren't properly freed.
As for fixing the memory leaks, you can turn on more debugging output to see where the memory leaks happened and where said memory was allocated. I think the flag is --leak-check=full or something like that (it tells you at the end what to put in). A lot of the "leaks" aren't actually problems, because they occur only when you quit the program without explicitly deleting things (which doesn't really matter in most cases because everything is freed on exit). You want to look for leaks that occur during normal execution of the program. For example, aborting a note might cause a memory leak if the various string pointers aren't properly freed.
#23 Jul 5, 2009 1:17 am
Magician
GroupMembers
Posts147
JoinedJun 9, 2009
Fixed two problems actually. I meant that I was able to erase 9 messages from a board without any noticeable issues. As for the second thing I fixed, it was a case of trying to free a null pointer in do_note_write under the SUB_NOTE_TEXT case in the switch statement.
As far as all those leaks, most of them are from the use of str_dup.
As far as all those leaks, most of them are from the use of str_dup.
#24 Jul 5, 2009 1:33 am
Sorcerer
GroupMembers
Posts870
JoinedMay 8, 2005
Andril said:
Oh, I'm not taking it lightly, especially since that's what's causing the crashes. And I fully intend to get that fixed before really worrying about the aborting message problem. So I'm off to find me a tutorial of some sort for valgrind.
Wow, Zeno missed a chance to post a link to Nick Gammon's tutorial on something?
#25 Jul 5, 2009 1:53 am
Last edited Jul 5, 2009 2:40 am by Andril
Magician
GroupMembers
Posts147
JoinedJun 9, 2009
Hmm, does Nick have a tutorial for valgrind on his forums? I only know about the one for gdb myself... Runs over there to look.
You lied to me...
You lied to me...
#26 Jul 5, 2009 2:16 am
Last edited Jul 5, 2009 2:17 am by Conner
Sorcerer
GroupMembers
Posts870
JoinedMay 8, 2005
Oops, looks like in this case Zeno's link wasn't for Gammon's, but it was Zeno's link.
Back on December 27, 2005, Zeno posted to 10 C Programming Questions: Long Winded Post the following:
Unfortunately, to the best of my knowledge, MudDomain closed down permanently about 6-12 months ago, so the link's probably not any good anymore, which would explain why Zeno didn't jump in to post it for you. Sorry for the false alarm.
Oh, wait, maybe this one's more useful/helpful, back on March 9, 2009, Zeno posted to Help Crashing the following:
At the very least, it's a much more recent link from him and sounds somewhat more promising, though I can't say that I've ever understood valgrind very well, even with reference to the docs.
Sadly enough, a quick search of this site's forum posts doesn't seem to have anything better than that to offer for you, but hopefully it's enough.
Back on December 27, 2005, Zeno posted to 10 C Programming Questions: Long Winded Post the following:
Zeno said:
6. Here's a good tutorial on using valgrind:
http://www.muddomain.com/articles/valgrind.php
(Since the site is down, had to use a backup of it)
EDIT: URL corrected to proper site.
Unfortunately, to the best of my knowledge, MudDomain closed down permanently about 6-12 months ago, so the link's probably not any good anymore, which would explain why Zeno didn't jump in to post it for you. Sorry for the false alarm.
Oh, wait, maybe this one's more useful/helpful, back on March 9, 2009, Zeno posted to Help Crashing the following:
Zeno said:
Here's the manual: http://valgrind.org/docs/manual/manual.html
I think you can install valgrind with yum.
At the very least, it's a much more recent link from him and sounds somewhat more promising, though I can't say that I've ever understood valgrind very well, even with reference to the docs.
Sadly enough, a quick search of this site's forum posts doesn't seem to have anything better than that to offer for you, but hopefully it's enough.
#27 Jul 5, 2009 2:46 am
Magician
GroupMembers
Posts147
JoinedJun 9, 2009
Yeah, I ended up just using a couple of different tutorials found through google ( Here and Here) as well as the valgrind.org manual to somewhat figure out what to do. Right now I'm looking at the cleanup_memory function in AFKMud to see about porting that over so valgrind will just ignore all of the junk that's supposed to stay in memory until the mud shuts down, thereby only reporting the things that are actual issues.
#28 Jul 5, 2009 5:15 am
Sorcerer
GroupMembers
Posts870
JoinedMay 8, 2005
Ah, well, I'm glad that you found some guides that were helpful then, and even better that you posted links to them here for others to benefit from as well.
#29 Jul 5, 2009 9:39 am
Magician
GroupMembers
Posts147
JoinedJun 9, 2009
I thought that would be nice of me as well.
I think they're both a little outdated, but most of the stuff still works just fine. The only real problem I had with what they show for the arguments to valgrind was for the log file. Need to use --log-file= and not --logfile=. But that was pretty much the only thing, plus there's a link at the bottom that goes to another page with some good descriptions of some of the error messages along with an explanation.
The second is probably more useful but I found them both handy...
I'd also STRONGLY suggest that everyone ports the cleanup_memory system from AFKMud. I've managed to learn quite a bit about how some of the stuff in the mud works while doing so.
Now I just have to figure out why one cat has decided to hang out on top of the refrigerator while the other one has usurped the kitchen counter...
I think they're both a little outdated, but most of the stuff still works just fine. The only real problem I had with what they show for the arguments to valgrind was for the log file. Need to use --log-file=
The second is probably more useful but I found them both handy...
I'd also STRONGLY suggest that everyone ports the cleanup_memory system from AFKMud. I've managed to learn quite a bit about how some of the stuff in the mud works while doing so.
Now I just have to figure out why one cat has decided to hang out on top of the refrigerator while the other one has usurped the kitchen counter...
#30 Jul 5, 2009 10:31 pm
Off the Edge of the Map
GroupAdministrators
Posts1,200
JoinedMar 21, 2006
All the FUSS bases should have cleanup_memory functions already...
#31 Jul 5, 2009 11:09 pm
Black Hand
GroupAdministrators
Posts3,697
JoinedJan 1, 2002
Andril said:
I'd also STRONGLY suggest that everyone ports the cleanup_memory system from AFKMud. I've managed to learn quite a bit about how some of the stuff in the mud works while doing so.
Now I just have to figure out why one cat has decided to hang out on top of the refrigerator while the other one has usurped the kitchen counter...
The cleanup_memory function is in at least SmaugFUSS as well, I don't recall if it ever got ported to the SWR/SWFotE side.
And the cats you see are merely the lookouts for the ones causing the real trouble, somewhere just out of sight.
#32 Jul 5, 2009 11:21 pm
Off the Edge of the Map
GroupAdministrators
Posts1,200
JoinedMar 21, 2006
Samson said:
And the cats you see are merely the lookouts for the ones causing the real trouble, somewhere just out of sight.
Isn't that the truth... *runs to see what that crash in the kitchen was*
#33 Jul 6, 2009 3:58 pm
Magician
GroupMembers
Posts147
JoinedJun 9, 2009
SWRFUSS/SWFotEFUSS don't have it.
After getting it in I went from 20,610 allocs, 6,082 frees and 700+ error messages to 19,634 allocs, 18,455 frees and 15 or so error messages. It's kind of nice going from around 20k blocks of not freed memory to only 1,179.
I used to have four cats and a dog. Now it's just the two cats thankfully.
After getting it in I went from 20,610 allocs, 6,082 frees and 700+ error messages to 19,634 allocs, 18,455 frees and 15 or so error messages. It's kind of nice going from around 20k blocks of not freed memory to only 1,179.
Kayle said:
Samson said:
And the cats you see are merely the lookouts for the ones causing the real trouble, somewhere just out of sight.
Isn't that the truth... *runs to see what that crash in the kitchen was*
I used to have four cats and a dog. Now it's just the two cats thankfully.
#34 Jul 6, 2009 5:03 pm
Geomancer
GroupAdministrators
Posts1,946
JoinedJul 26, 2005
Conner said:
Oops, looks like in this case Zeno's link wasn't for Gammon's, but it was Zeno's link.
Back on December 27, 2005, Zeno posted to 10 C Programming Questions: Long Winded Post the following:
Zeno said:
6. Here's a good tutorial on using valgrind:
http://www.muddomain.com/articles/valgrind.php
(Since the site is down, had to use a backup of it)
EDIT: URL corrected to proper site.
Unfortunately, to the best of my knowledge, MudDomain closed down permanently about 6-12 months ago, so the link's probably not any good anymore, which would explain why Zeno didn't jump in to post it for you. Sorry for the false alarm.
Well I'm the one that created that article if I remember right (sorry don't have a copy of it around either did it long long ago, around the time cleanup_memory got put into everything to stop giving so many warnings). But I never realized it was considered a good article either lol. It was just something to cover the basics of using it. Not sure where you could find a copy of it unless Paradigm happens to have a copy of it around somewhere.
#35 Jul 7, 2009 1:34 am
Sorcerer
GroupMembers
Posts870
JoinedMay 8, 2005
Damn, Remy, don't you save anything you write?
#36 Jul 7, 2009 3:22 am
Black Hand
GroupAdministrators
Posts3,697
JoinedJan 1, 2002
You're talking about the guy who deleted 3 prior incarnations of his codebase that were all farther along than what's out now
If he didn't deem the article worthy of much, deleting it seems to fit the profile here.
If he didn't deem the article worthy of much, deleting it seems to fit the profile here.
#37 Jul 7, 2009 5:23 am
Geomancer
GroupAdministrators
Posts1,946
JoinedJul 26, 2005
lol well the number depends on what you consider more advanced I use to restart the code a few times a year over all. I'd go various directions with lots of different things on a base till I got bored and then start over lol. Normally each time I started over I'd go a different direction. One of the few old copies I still have, still has a lot of stuff I haven't added to the current one lol. One of these days I might actually take the time to tear it down and use some of it.
#38 Dec 22, 2010 12:19 pm
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005
Conner said:
Oops, looks like in this case Zeno's link wasn't for Gammon's, but it was Zeno's link.
Back on December 27, 2005, Zeno posted to 10 C Programming Questions: Long Winded Post the following:
Zeno said:
6. Here's a good tutorial on using valgrind:
http://www.muddomain.com/articles/valgrind.php
(Since the site is down, had to use a backup of it)
EDIT: URL corrected to proper site.
Unfortunately, to the best of my knowledge, MudDomain closed down permanently about 6-12 months ago, so the link's probably not any good anymore, which would explain why Zeno didn't jump in to post it for you. Sorry for the false alarm.
Oh, wait, maybe this one's more useful/helpful, back on March 9, 2009, Zeno posted to Help Crashing the following:
Zeno said:
Here's the manual: http://valgrind.org/docs/manual/manual.html
I think you can install valgrind with yum.
At the very least, it's a much more recent link from him and sounds somewhat more promising, though I can't say that I've ever understood valgrind very well, even with reference to the docs.
Sadly enough, a quick search of this site's forum posts doesn't seem to have anything better than that to offer for you, but hopefully it's enough.
Could always use archive.org
http://web.archive.org/web/20051230054113/http://www.muddomain.com/articles/valgrind.php
(Talk about late)
#39 Dec 22, 2010 6:30 pm
Sorcerer
GroupMembers
Posts870
JoinedMay 8, 2005
No kidding about being a bit late on that one.