O Memory - Testing with Simobject
by Thomas Huehn · in Torque Game Engine · 08/23/2008 (10:08 am) · 10 replies
The memory manager is still a mistery to me. I wrote some small test scripts which can be paste on console and the result is: where is my memory gone? I did not make a leak test for it because I'am using simple SimObjects which should be clean from leaks ?!
The test and the used memory - tested it on dedicated server:
Mem: 59368
Mem: 66380
Mem: 66388 ... 8 bytes gone for delete ?
Mem: 68748
Mem: 68760
Mem: 72516
Mem: 72520
The next test make the real curiosity. I know strings are cached and not allways the memory is released but the next loop should use no extra memory but ....
Mem: 81176 !!!!!!!!
Mem: 81192
Thats really a bad thing when working on a mmo and handling a lot of data like user stats.
The test and the used memory - tested it on dedicated server:
Mem: 59368
for ($j=0;$j<100;$j++) {$u="testo"@$j; new SimObject($u);for ($i=0;$i<1000;$i++) $u.setfieldvalue($u@"XXX" @ $i, $u@"XXXX" @ $i);}Mem: 66380
for ($j=0;$j<100;$j++) {$u="testo"@$j; $u.delete();}Mem: 66388 ... 8 bytes gone for delete ?
for ($j=100;$j<200;$j++) {$u="testo"@$j; new SimObject($u);for ($i=0;$i<1000;$i++) $u.setfieldvalue($u@"XXX" @ $i, $u@"XXXX" @ $i);}Mem: 68748
for ($j=100;$j<200;$j++) {$u="testo"@$j; $u.delete();}Mem: 68760
for ($j=200;$j<300;$j++) {$u="testo"@$j; new SimObject($u);for ($i=0;$i<1000;$i++) $u.setfieldvalue($u@"XXX" @ $i, $u@"XXXX" @ $i);}Mem: 72516
for ($j=200;$j<300;$j++) {$u="testo"@$j; $u.delete();}Mem: 72520
The next test make the real curiosity. I know strings are cached and not allways the memory is released but the next loop should use no extra memory but ....
for ($j=0;$j<300;$j++) {$u="testo"@$j; new SimObject($u);for ($i=0;$i<1000;$i++) $u.setfieldvalue($u@"XXX" @ $i, $u@"XXXX" @ $i);}Mem: 81176 !!!!!!!!
for ($j=0;$j<300;$j++) {$u="testo"@$j; $u.delete();}Mem: 81192
Thats really a bad thing when working on a mmo and handling a lot of data like user stats.
About the author
Contact: torque [AT] ohmtal [DOT] com
#2
08/23/2008 (11:39 am)
Thats true, but why allocate it nearly 10 MB on the last 2 loops. The nodenames was added to stringtable before and the values should use memory which was deallocated before and kept in the memory manager.
#3
I would not implement an MMO's game logic in TorqueScript if I could help it.
08/23/2008 (3:18 pm)
Property values may be kept locally copied. How are you measuring memory usage, by the way? Torque's memory manager, or task manager, or what?I would not implement an MMO's game logic in TorqueScript if I could help it.
#4
lol. that's what we've done w/ vSide. at least the game engine aspects. the backend is java.
in retrospect it might have been good to spend the time up-front to bind python or javascript or somesuch.
what would you recommend ?
08/23/2008 (3:32 pm)
> I would not implement an MMO's game logic in TorqueScript if I could help it.lol. that's what we've done w/ vSide. at least the game engine aspects. the backend is java.
in retrospect it might have been good to spend the time up-front to bind python or javascript or somesuch.
what would you recommend ?
#5
Ritter got a ton of mileage out of Python. Java has the right toolset and feature focus to work well in the MMO space, too.
Tamarin (the AS3 runtime) is really fast and has good tools and libraries thanks to the Flash community. I did a talk on Tamarin at GDC, see , and its only gotten better since then.
08/23/2008 (4:06 pm)
I'd go with a well known well supported scripting language with lots of helpful libraries. The goal is productivity and maintenance so it's a decision to be made in context of the developers who will be working on it. :)Ritter got a ton of mileage out of Python. Java has the right toolset and feature focus to work well in the MMO space, too.
Tamarin (the AS3 runtime) is really fast and has good tools and libraries thanks to the Flash community. I did a talk on Tamarin at GDC, see
#6
yeah, i read your talk from coderhump. i didn't realize that tamarin was the VM for javascript.
i'm excited to read about the addition of tracing.
08/23/2008 (4:26 pm)
Clint Brewer bound ruby to TGE, but i'm not sure how extensively he's used it.yeah, i read your talk from coderhump. i didn't realize that tamarin was the VM for javascript.
i'm excited to read about the addition of tracing.
#7
Besides the performance characteristics, which are awesome, it's a very useful and pragmatic language.
08/23/2008 (4:38 pm)
It's the runtime for Flash's scripting language, which is basically typed javascript, and the mozilla guys are starting to use it, too.Besides the performance characteristics, which are awesome, it's a very useful and pragmatic language.
#8
As I understand the sourcecode the key (fieldname/slotname) is stored in the global stringtable which cause raising the memory to speedup the access for the key / global script variables. The value string is not stored in the stringtable and released in SimFieldDictionary::~SimFieldDictionary(). Thats why i don't understand the last raising. I create same count of SimObjects and send the same key's and values like before.
08/24/2008 (3:26 am)
Quote:How are you measuring memory usage, by the way?This test was made on my BSD Server using the rss (the real memory (resident set) size of the process) from 'ps -aux'. A other test was made on windows looking at taskmanager shows the same result.
As I understand the sourcecode the key (fieldname/slotname) is stored in the global stringtable which cause raising the memory to speedup the access for the key / global script variables. The value string is not stored in the stringtable and released in SimFieldDictionary::~SimFieldDictionary(). Thats why i don't understand the last raising. I create same count of SimObjects and send the same key's and values like before.
#9
08/24/2008 (6:23 am)
Finally I found my memory problem. It was not related to the simobjects I use. I use the md5file resource (http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=10795) also for password verification. And there was made a strdup which was never freed again, before I tweaked it ;)
#10
08/24/2008 (1:13 pm)
Good to hear, thanks for posting.
Torque Owner Nathan Kent