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 (Grant, AndrewAMD), 911 guests, and 9 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
STRING declaration #331676
07/05/10 17:37
07/05/10 17:37
Joined: Sep 2009
Posts: 987
Budapest
Aku_Aku Offline OP
User
Aku_Aku  Offline OP
User

Joined: Sep 2009
Posts: 987
Budapest
Today i have found the Scripts part of the Wiki.
There is an interesting entry about STRING declaration.
The author is EvilSOB and he stated this (for local STRING variables):
Quote:
you need to call str_remove on these strings before you terminate the function, otherwise the string pointer will be lost and remain using that memory until application close

Is it true for the latest A7?
What about with other local variables, var, int etc.?

Re: STRING declaration [Re: Aku_Aku] #331678
07/05/10 17:48
07/05/10 17:48
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
This is not true for global strings that are defines outside a function like this:
STRING* my_string = "Hello!";

However, if you create your string with str_create within a function like this:
STRING* my_string = str_create("Hello!");
then, you'll have to remove it with ptr_remove at the end of the function if you don't need it anymore. Otherwise it indeed stays in the memory and the memory consumption of your game increases each time you call that function.

Re: STRING declaration [Re: Lukas] #331687
07/05/10 18:49
07/05/10 18:49
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Its still true with the latest A7, and will probably always be the case.

After all, this IS NOT a flaw, it is most often a good thing...
Think how difficult it would be if you could create entities in
a function, like bullets, but they cease to exist as soon as
that function finishes...

It is only applicable for objects that you manually create using an
engine 'create' function. EG ent_create, bmap_create, str_create....
(OR sys_malloc if you are ready for that yet....)





"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: STRING declaration [Re: Lukas] #331689
07/05/10 18:52
07/05/10 18:52
Joined: Sep 2009
Posts: 987
Budapest
Aku_Aku Offline OP
User
Aku_Aku  Offline OP
User

Joined: Sep 2009
Posts: 987
Budapest
Thanks, as i wrote i ment local string.
So, thank for the info.
What is the situation when the acknex is crashed?

Re: STRING declaration [Re: Aku_Aku] #331695
07/05/10 19:08
07/05/10 19:08
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Quote:
... as i wrote i ment local string.
Yeah, I figured as much.

In the case of a application crash, sometimes all the memory gets
cleared, sometimes it doesnt.

But thats more or less up to how well windows handled the crash.

It depends a lot on what type of illegal operation it was that caused the crash...
If windows got upset about what acknex was doing, it can be bad.
If acknex saw a fault and crashes out, its usually pretty clean.

Ive had as much as 750M of ram locked out after a bad 'malloc' command.
But EXACTLY the same fault when using 'sys_malloc' and I lost no memory.
Thats because (as far as I can tell) the malloc got caught by windows,
whereas the sys_malloc got caught by acknex.





"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial

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