well here's how i generally attempt to track down memory leaks... it's not
foolproof, but it'll at least get you started on it... first i put in a wiznet
option that shows when memory is allocated, just drop it into void interpret
and have it assign a couple of variables to equal the nAllocPerm and
nAllocString variables, then after the command function is called have it check
if nAllocPerm and nAllocString are greater than the variables you just assigned
to their previous values, and if so to wiznet a message w/ the player name,
command name, and the difference in values (like +5) or something... then if
you execute a command and you see it allocating memory for it, that's normal,
but if after that, you can perform the command, and everytime you do, it
allocates more memory, there's a leak in it... at that point you can load gdb
and attach it to the running mud process like so:
ps -ux
(get the mud's pid value and from the src directory)
gdb ./rom <pid value>
then do this (if it's allocating perm use the perm variable, or string for
those instead):
watch nAllocPerm
continue
Then jump over to your mud window and perform the command and gdb should trap
it when the mud tries to increase nAllocPerm... at that point do a backtrace
(bt command) and jump down to the frame with the command function for the
command you just entered... see which line it jumped to the next function call
on, and that's generally where your leak is... you could have leaks due to
things like this:
obj->name = str_dup(fread_string(fp));
as fread_string allocates one block of memory, and str_dup does another, which
can be freed, but then the fread allocation eats up a chunk that doesn't get
freed... anyway that should point you in the right direction...
wavewave
Richard Lindsey.
-----Original Message-----
From: Rainer Roomet [mailto:[EMAIL PROTECTED]
Sent: Sat 5/8/2004 5:40 AM
To: [email protected]
Cc:
Subject: MEMORY leaks
I have few questions about memory leaks.
1) how i can detect memory leaks ?
2) what causes memory leaks?
3) how i can fix memory leaks ?
4) anyone knows some URL about memory leaks?
- Ranka
Owner: The Lost Lands of Arion
http://www.zone.ee/gain/
telnet://irc.nohik.ee 4242
_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
http://join.msn.com/?page=features/virus
--
ROM mailing list
[email protected]
http://www.rom.org/cgi-bin/mailman/listinfo/rom