|
2 registered members (juanex, AndrewAMD),
988
guests, and 8
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Memory Consumption
#360193
02/22/11 18:45
02/22/11 18:45
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
OP
Expert
|
OP
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
Hi!
I've checked the Task Manager earlier today, while my game is running. According to the task manager, the memory usage increases steadily over time. But the F11 Panel doesn't show increasing numbers in game. So what does this mean? Should not all memory consumption be shown on the F11 Panel? If I have a leak, are there tools in LiteC to find it? I have a lot of memory allocation/freeing, and since I only noticed this now, it could be everywhere...
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: Memory Consumption
[Re: muffel]
#360224
02/22/11 20:39
02/22/11 20:39
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
OP
Expert
|
OP
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
I'm using sys_malloc, but I'm also using some list functions written by other users, so I'll have to check what they do.
I will look into the sys_marker: Thanks for the hint, I didn't know it could be used for that as well. What does sys_marker(NULL); do? I don't understand the manual there. It "resets" the marker? Does that mean this code will only "debug" the first memory allocation?
sys_marker("TST"); //a memory leak in mem will be shown in acklog... char* mem = sys_malloc(123); int i; for (i=0; i<128; i++) mem[i] = 'A'; sys_marker(NULL); //... but a mem leak of mem2 will not? char* mem2 = sys_malloc(123); for (i=0; i<128; i++) mem2[i] = 'A';
About the F11 Panel: Does anyone know what the difference between the numbers there and the number that windows shows is?
Last edited by Germanunkol; 02/22/11 20:39.
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: Memory Consumption
[Re: Germanunkol]
#360258
02/22/11 22:56
02/22/11 22:56
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
OP
Expert
|
OP
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
Aaaaand I wanna add another question: I use multiple VECTORs that are local, in functions. It looks like:
void xyz()
{
VECTOR temp;
...
}
Do those get removed automatically? I was never sure about this... vars and pointers get invalid/removed after the function is done, right? And STRINGs need to be removed manually. But what about VECTORs?
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
Re: Memory Consumption
[Re: Germanunkol]
#360264
02/22/11 23:30
02/22/11 23:30
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
The memory consumption is calculated by summing up all memory areas allocated by the engine at runtime, i.e. the level, textures, memory allocated by the script and so on. It does not include memory that is on the stack or that is used by external plugins. Texture memory on the video device isn't taken into account as well. If you allocate memory by using malloc or realloc this does not add to the value as well. Everything you define in a function gets on the stack and is automatically removed. That means your vector in your example will be removed. But be carefull. If you do something like this:
void foo()
{
STRING* s = str_create("bar");
}
then the four bytes for the pointer will be automatically removed as soon as foo() terminates, the string itself will remain on the heap.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: Memory Consumption
[Re: Uhrwerk]
#360276
02/23/11 06:02
02/23/11 06:02
|
Joined: Oct 2004
Posts: 4,134 Netherlands
Joozey
Expert
|
Expert
Joined: Oct 2004
Posts: 4,134
Netherlands
|
Be careful with vectors in general. They are always removed after a while: Vector(x,y,z): The vector pointers have a limited lifetime because there are only 64 different vectors available for this function, that are used cyclic.So use this only for passing temporary vectors to functions, but not for permanent vector pointers.
I have no idea how true this is. Maybe JCL has invented linked lists in the meantime, and forgot to update the manual.
Last edited by Joozey; 02/23/11 22:42.
Click and join the 3dgs irc community! Room: #3dgs
|
|
|
Re: Memory Consumption
[Re: Myrkling]
#360440
02/23/11 22:43
02/23/11 22:43
|
Joined: Oct 2004
Posts: 4,134 Netherlands
Joozey
Expert
|
Expert
Joined: Oct 2004
Posts: 4,134
Netherlands
|
Right, I adapted the quote to prevent future misunderstanding, thanks  . The best way to define a vector to use outside a function would then be (to my understanding): VECTOR *vec = sys_malloc( sizeof( VECTOR )); vec_set( vec, nullvector );
Click and join the 3dgs irc community! Room: #3dgs
|
|
|
|