Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ MUSH has memory leak?

MUSH has memory leak?

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Phoenixdie   (3 posts)  Bio
Date Fri 12 Feb 2010 02:11 PM (UTC)

Amended on Fri 12 Feb 2010 09:22 PM (UTC) by Nick Gammon

Message
hi,i'm from china,my english not so good,may be i can't express clearly.when i play mud with mush,it takes more and more memory,at last crash. has some wrong with my lua script?
follows



room description:
map_nanyang={
	[1]={
		roomid=1,
		roomname="æäµÀ",
		roomindex=1,
		roomnumber=1,
		roomflag=0,
		roomnpc={},
		roomdes="ÕâÊÇÄÏÑô¸®¾³ÄÚµÄÒ»ÌõæäµÀ¡£Â·ÉÏÈËÀ´ÈËÍù£¬³¾ÍÁ·ÉÑï¡£²»Ê±ÓÐÁ½ÈýÆï¿ìÂí·É³Û¶ø¹ý£¬ÑïÆðһ·³¾°£¡£ÂíÉϵÄÈ˸ö¸öÉíמ¢×°£¬Ò¼×ÏÊÃ÷£¬ÓеĻ¹ËæÉíÅå´ø×ŵ¶½£¡£¿´À´¶¼ÊÇЩϰÎäµÄ½­ºþÈË¡£µÀ·Á½ÅÔÊÇÕûÕûÆëÆëµÄÑîÊ÷ÁÖ¡£´ÓÕâÀïÏò±±Ò»Ö±×ß¾ÍÊÇÄÏÑô³ÇÁË¡£",
		roomcx=0,
		roomcy=0,
		roomcz=0,
		roomexists={
			["e"]=9,
			["n"]=2
		}
	},
	[2]={
		roomid=2,
		roomname="ÄÏÃÅ",
		roomindex=1,
		roomnumber=1,
		roomflag=0,
		roomnpc={},
		roomdes="ÕâÀïÊÇÄÏÑô¸®µÄÄϳÇÃÅ£¬ÒòΪÄÏÑôµØ´¦ÓÚÏåÑô±±È¥µÄÒª³å£¬ËùÒÔ·ÉÏÍùÀ´µÄÈ˺ܶࡣ¸Ï³µµÄÂí·ò¡¢ÉϾ©¸Ï¿¼µÄÊéÉú¡¢Ìôµ£µÄ½Å·ò¡¢ÍƳµµÄС··¡¢ÎõÎõÈÁÈÁ£¬ºÜÊÇÈÈÄÖ¡£²»Ê±ÓÐÁ½ÈýÆï¿ìÂí´ÓÉí±ß·É³Û¶ø¹ý£¬ÑïÆðһ·³¾°£¡£",
		roomcx=0,
		roomcy=-1,
		roomcz=0,
		roomexists={
			["s"]=1,
			["n"]=3
		}
	},
	[3]={
		roomid=3,
		roomname="ʯ°å·",
		roomindex=1,
		roomnumber=1,
		roomflag=0,
		roomnpc={},
		roomdes="ÕâÊÇÄÏÑô³ÇÖеÄÒ»Ìõʯ°å·£¬½ÖµÀ²»ÊÇºÜ¿í£¬Á½±ßÔÔ×ÅÐí¶à°×ÑîÊ÷¡£Â·ÉÏÍùÀ´µÄÐÐÈË£¬Óм¸¸ö´Ó×°ÊøÀ´¿´ËƺõÊÇÎäÁÖÖÐÈË¡£ËûÃÇÒ»¸ö¸öÐÐÉ«´Ò´Ò´ÓÄãÉí±ß¾­¹ý£¬Íù¶«±ßµÄ²íµÀ¶øÈ¥¡£»¹ÓÐЩ¸Ï×Å´ó³µµÄÂí·ò£¬Ðе½ÕâÀïºóÒ²·×·×¹ÕÉÏÁËÏò¶«µÄ²íµÀ£¬¶«±ßµÄ²íµÀͨÍùÐí¼Ò¼¯¡£",
		roomcx=0,
		roomcy=-2,
		roomcz=0,
		roomexists={
			["e"]=4,
			["s"]=2,
			["n"]=14
		}
	},
	[4]={
		roomid=4,
		roomname="С·",
		roomindex=1,
		roomnumber=2,
		roomflag=0,
		roomnpc={},
		roomdes="ÕâÊÇÒ»ÌõƧ¾²µÄС·£¬Á½ÅÔÊÇïÃܵĴÔÁÖ¡£Â·ÉÏÒÀÏ¡¿É¼û³µÂí×ß¹ýÁôϵĺۼ£¡£Å¼¶ûÓм¸¸öÐÐÈËÐÐÉ«´Ò´Ò´ÓÄãÉí±ß¾­¹ý£¬Íù¶«±ßµÄÐí¼Ò¼¯¶øÈ¥¡£Î÷Ãæ·½ÏòÊÇÄÏÑô³Ç¡£",
		roomcx=1,
		roomcy=-2,
		roomcz=0,
		roomexists={
			["e"]=5,
			["w"]=3
		}
	},
	[5]={
		roomid=5,
		roomname="Çàʯ·",
		roomindex=1,
		roomnumber=2,
		roomflag=0,
		roomnpc={},
		roomdes="ÕâÊÇÐí¼Ò¼¯ÉϵÄÒ»ÌõÇàʯ·£¬Â·ÃæÉÏÆÌ×ÅÒ»²ãϸËéµÄʯ×Ó£¬Â·ÉϵÄÐÐÈ˲»¶à¡£ÄÏÃæÊÇÐí¼Ò¼¯µÄÊм¯¡£¶«ÃæÓÐÒ»ÌõС·ͨÍù¾ÛÏÍׯ¡£",
		roomcx=2,
		roomcy=-2,
		roomcz=0,
		roomexists={
			["e"]=10,
			["s"]=6,
			["w"]=4
		}
	},
	[6]={
		roomid=6,
		roomname="Ðí¼Ò¼¯",
		roomindex=1,
		roomnumber=1,
		roomflag=0,
		roomnpc={},
		roomdes="ÕâÊÇÄÏÑô¸½½üµÄÐí¼Ò¼¯£¬Êм¯ÉϺÜÈÈÄÖ£¬¸½½üµÄÅ©Ãñ¾­³£µ½ÕâÀïÀ´½»Ò××Ô¼ºÐÁ¿àÀͶ¯µÄ³É¹û¡£¼¯ÊÐÅÔ±ßÓÐÆ¬¿ÕµØ£¬Í£×ż¸Á¾Âí³µ¡£¶«ÃæÓмҿÍÕ»£¬ÃÅ¿ÚÕý¶Ô×ÅÕâÀï¡£",
		roomcx=2,
		roomcy=-1,
		roomcz=0,
		roomexists={
			["e"]=7,
			["sw"]=9,
			["s"]=8,
			["n"]=5
		}
	},
	[7]={
		roomid=7,
		roomname="¿ÍÕ»",
		roomindex=1,
		roomnumber=1,
		roomflag=0,
		roomnpc={},
		roomdes="ÕâÊǸ½½üÔ¶½üÎÅÃûµÄÔÃÀ´¿ÍÕ»£¬ÉúÒâ·Ç³£ÐË¡¡£ÍâµØÓοͶàÑ¡ÔñÔÚÕâÀïÂä½Å£¬Äã¿ÉÒÔÔÚÕâÀï´òÌýµ½¸÷µØµÄ·çÍÁÈËÇé¡£µêС¶þÀïÀïÍâÍâæµÃÍÅÍÅת£¬½Ó´ý×ÅÄÏÇ»±±µ÷µÄ¿ÍÈË¡£Ç½ÉϹÒ×ÅÒ»¸öÅÆ×Ó(paizi)¡£",
		roomcx=3,
		roomcy=-1,
		roomcz=0,
		roomexists={
			["w"]=6
		}
	},
	[8]={
		roomid=8,
		roomname="Çàʯ·",
		roomindex=2,
		roomnumber=2,
		roomflag=0,
		roomnpc={},
		roomdes="ÕâÊÇÐí¼Ò¼¯ÉϵÄÒ»ÌõÇàʯ·£¬Â·ÃæÉÏÆÌ×ÅÒ»²ãϸËéµÄʯ×Ó£¬Â·ÉϵÄÐÐÈ˲»¶à¡£±±ÃæÊÇÐí¼Ò¼¯µÄÊм¯¡£",
		roomcx=2,
		roomcy=0,
		roomcz=0,
		roomexists={
			["n"]=6
		}
	},
	[9]={
		roomid=9,
		roomname="²í·",
		roomindex=1,
		roomnumber=1,
		roomflag=0,
		roomnpc={},
		roomdes="ÕâÊÇÒ»ÌõƧ¾²µÄС·£¬Á½ÅÔÊÇïÃܵĴÔÁÖ¡£Â·ÉÏÒÀÏ¡¿É¼û³µÂí×ß¹ýÁôϵĺۼ£¡£´ÓÕâÀïÍù¶«±±·½ÏòÊÇÄÏÑô¸®Ðí¼Ò¼¯£¬Î÷±ß·½Ïò×ßÊÇͨÍùÏåÑôºÍÄÏÑôÖ®¼äµÄÒ»ÌõæäµÀ¡£",
		roomcx=1,
		roomcy=0,
		roomcz=0,
		roomexists={
			["ne"]=6,
			["w"]=1
		}
	},
	[10]={
		roomid=10,
		roomname="С·",
		roomindex=2,
		roomnumber=2,
		roomflag=0,
		roomnpc={},
		roomdes="ÕâÊÇÒ»ÌõƧ¾²µÄС·£¬Á½ÅÔÊÇïÃܵĴÔÁÖ¡£Â·ÉÏÒÀÏ¡¿É¼û³µÂí×ß¹ýÁôϵĺۼ£¡£´ÓÕâÀïÍù¶«±±·½ÏòÊǸ½½üÔ¶½üÎÅÃûµÄ¾ÛÏÍׯ£¬Î÷ÃæÊÇͨÍùÐí¼Ò¼¯µÄÇàʯ·¡£ÕâÀïÆ½³£Ã»ÓÐʲôÈË¡£",
		roomcx=3,
		roomcy=-2,
		roomcz=0,
		roomexists={
			["ne"]=11,
			["w"]=5
		}
	},
	[11]={
		roomid=11,
		roomname="¾ÛÏÍׯ´óÃÅ",
		roomindex=1,
		roomnumber=1,
		roomflag=0,
		roomnpc={},
		roomdes="Äã×ßµ½Ò»×ù¸ßÕ¬´óÔºµÄÃſڣ¬´óÃÅ¿ª×Å£¬ÃÅǰ×óÓÒÓÐÁ½¸öʯʨ×Ó£¬ËÄÎå¼¶Çàʯ̨½×ÉÏÊÇÁ½Éȶ¤ÂúÍ­¶¤µÄ´óÃÅ¡£¿´µÃ³öÕâÀïÊÇÒ»´ó»§È˼ҵÄסËù¡£ÃÅ¿ÚÕýÖÐÑë¸ßÐü×ÅÒ»¿éºÚµ×½ð×ֵĴóØÒ£¬ØÒÉÏдÓÐÈý¸ö´ó×Ö£º¡¾¾ÛÏÍׯ¡¿¡£",
		roomcx=4,
		roomcy=-3,
		roomcz=0,
		roomexists={
			["sw"]=10,
			["n"]=12
		}
}

walk lua script:
--»ñÈ¡·¿¼äsid,didÖ®¼äµÄ·¾¶
function getroompath(city,sid,did)
	local bestroom,temproom
	openlist={}
	closedlist={}
	if sid==did then return "" end
	table.insert(openlist,createnode(sid,0,"",nil,nil))
	while table.getn(openlist)~=0 do
		table.sort(openlist,function(a,b) return a.g<b.g end)
		bestroom=openlist[1]
		if bestroom.key==0 then
			print(city.."·¿¼ä"..bestroom.prevnode.."Óгö¿ÚÖ¸Ïò0£¬Çë²éÖ¤")
			return ""
		end
		table.remove(openlist,1)
		if not checkclosedlist(bestroom.key) then closedlist[bestroom.key]=bestroom end
		if bestroom.key==did then return getpathfromlist(sid,did) end
		for k,v in pairs(sjmap[city][bestroom.key].roomexists) do
			if not checkopenlist(v) then
				if not checkclosedlist(v) then table.insert(openlist,createnode(v,bestroom.g+1,k,bestroom.key,nil)) end
			end
		end
	end
end

function checkopenlist(key)
	for k,v in pairs(openlist) do
		if key==v.key then return true end
	end
	return false
end

function checkclosedlist(key)
	if closedlist[key]~=nil then
		return true
	else
		return false
	end
end
function getpathfromlist(sid,did)
	local tmp
	local path=""

	tmp=closedlist[did]
	path=tmp.path
	while tmp.prevnode~=sid do
		tmp=closedlist[tmp.prevnode]
		path=tmp.path..";"..path
	end
	return path
end



has memory leak in my code?
thanks
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 12 Feb 2010 06:41 PM (UTC)
Message
Template:version Please help us by advising the version of MUSHclient you are using. Use the Help menu -> About MUSHclient.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Phoenixdie   (3 posts)  Bio
Date Reply #2 on Sat 13 Feb 2010 09:16 AM (UTC)
Message
ver 4.18
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Sat 13 Feb 2010 08:43 PM (UTC)
Message
A serious memory leak was fixed in version 4.25:

http://www.gammon.com.au/scripts/showrelnote.php?version=4.25&productid=0

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #4 on Sat 13 Feb 2010 08:44 PM (UTC)
Message
You are advised to upgrade to at least version 4.43:

http://www.gammon.com.au/downloads/dlmushclient.htm

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


18,285 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.