Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
auth_update crash
Dec 23, 2017, 10:15 pm
By Remcon
check_tumble
Dec 18, 2017, 7:21 pm
By Remcon
parse description bug
Dec 15, 2017, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex

Members: 0
Guests: 9
Stats
Files
Topics
Posts
Members
Newest Member
478
3,708
19,242
612
Jacki72H
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » General » Smaug Snippets » overland bug
Forum Rules | Mark all | Recent Posts

overland bug
< Newer Topic :: Older Topic > memory leak

Pages:<< prev 1 next >>
Post is unread #1 Feb 1, 2004, 12:55 pm
Go to the top of the page
Go to the bottom of the page

Eos

GroupMembers
Posts7
JoinedNov 29, 2002

in db.c the load_continent section:
value = get_continent( fread_string(fp) );

should be:

char *pointer
pointer = fread_string_nohash( fp);
value = get_continent( pointer);
DISPOSE( pointer);

or some similar variation.
Otherwise this string is:

A) Being allocated and never disposed of
B) Being added to the hash table with no way to remove it.

I didn't see this one reported yet so thought I'd share.
       
Post is unread #2 Feb 1, 2004, 10:24 pm
Go to the top of the page
Go to the bottom of the page

Xorith
The Null Value
GroupAFKMud Team
Posts254
JoinedFeb 23, 2003

Wouldn't...

value = get_continent( fread_string_nohash( fp ) );


Also work? Rather than allocating a pointer and going a bit round about.

-- X
       
Post is unread #3 Feb 2, 2004, 1:05 am
Go to the top of the page
Go to the bottom of the page

Greven
Magician
GroupMembers
Posts204
JoinedMar 5, 2005

Not really, cause fread_string_nohash still allocates the memory with str_dup, it just doesn't save it anywhere except in random memory. it will pass it on to get_continent, but from there there is no way to deallocate the memory assigned. Don't quote me, but I think the technical term is called a lost memory pointer. Then again, what do I know?
       
Post is unread #4 Feb 2, 2004, 3:33 am
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Yes, Eos is actually quite correct in the method he chose. Internally for AFKMud we just use the fread_flagstring function to accomplish such readings, but that doesn't exist in Smaug so most code which needs to read words like that is usually just passed to fread_string and is the cause of many leaks in Smaug snippets and code in general.

I really should take some time to go over every last bit of code I have and bring them all as up to date.
       
Post is unread #5 Feb 2, 2004, 5:23 am
Go to the top of the page
Go to the bottom of the page

Eos

GroupMembers
Posts7
JoinedNov 29, 2002

Does your fread_flagstring just return a static local variable to avoid allocating memory? I use a function I made that way (fread_string_noallocate) to do that and keep things short.
       
Post is unread #6 Feb 3, 2004, 3:31 am
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

It's just a copy of fread_string that returns a static variable instead of STRALLOC'ing it. But yes, it avoids the need to allocate memory for temporary strings.
       
Pages:<< prev 1 next >>