Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
2 registered members (juanex, AndrewAMD), 988 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Memory Consumption #360193
02/22/11 18:45
02/22/11 18:45
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline OP
Expert
Germanunkol  Offline 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: Germanunkol] #360194
02/22/11 18:50
02/22/11 18:50
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
How do you allocate your memory, sys_malloc/nx or malloc?


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Memory Consumption [Re: Superku] #360195
02/22/11 18:54
02/22/11 18:54
Joined: Oct 2009
Posts: 149
Germany
M
muffel Offline
Member
muffel  Offline
Member
M

Joined: Oct 2009
Posts: 149
Germany
sys_marker can detect memory leaks if you are using the sys_malloc,sys_... commands for managing memory
muffel

Re: Memory Consumption [Re: muffel] #360224
02/22/11 20:39
02/22/11 20:39
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline OP
Expert
Germanunkol  Offline 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 Offline OP
Expert
Germanunkol  Offline 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:
Code:
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 Offline
Expert
Uhrwerk  Offline
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:
Code:
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 Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Be careful with vectors in general. They are always removed after a while:
Quote:

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: Joozey] #360286
02/23/11 08:41
02/23/11 08:41
Joined: Feb 2011
Posts: 135
Myrkling Offline
Member
Myrkling  Offline
Member

Joined: Feb 2011
Posts: 135
It should be noted that the quote above refers to vector pointers returned by vector(), not vector pointers in general.

Re: Memory Consumption [Re: Myrkling] #360440
02/23/11 22:43
02/23/11 22:43
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Right, I adapted the quote to prevent future misunderstanding, thanks laugh.

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

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1