Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] [ Tier-2 ] agk::GetStringToken bug ??

Author
Message
SkinK4ir3
8
Years of Service
User Offline
Joined: 25th Aug 2015
Location:
Posted: 15th Jul 2023 20:20
Hello everyone, I'm currently using the function: agk::GetStringToken in my code and I noticed some "strange" behavior, if I keep agk::GetStringToken inside a loop waiting for the user's choice, the use of ram memory only increases
(already got to the point of starting with 50mb and getting 400mb of constant ram usage)...
Is there a way to make this more optimized?

I don't know how I should treat this, because I'm starting with c++ for now...

Does anyone have any idea what could be going on?

The author of this post has marked a post as an answer.

Go to answer

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 15th Jul 2023 22:30 Edited at: 15th Jul 2023 22:34
moved from Showcase to Classic chat... (i wonder why Tier 2 chat is no longer available?).
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 16th Jul 2023 02:41 Edited at: 16th Jul 2023 02:42
I seem to recall that anytime a Tier 2 AppGameKit function returned a string you had to free/release/destroy it when you finished using it

This is a Note from another function (StripString());
"Note that if you are calling this command from tier 2 then the returned string must be deleted when you are done with it."

SkinK4ir3
8
Years of Service
User Offline
Joined: 25th Aug 2015
Location:
Posted: 16th Jul 2023 03:07 Edited at: 16th Jul 2023 03:08
would you have any example of how to " free/release/destroy " correctly?

I tried using

but it still keeps increasing the memory of the application consecutively
Dark Raven
9
Years of Service
User Offline
Joined: 27th Jul 2014
Location: United States
Posted: 16th Jul 2023 03:14 Edited at: 16th Jul 2023 03:16
DeleteString must be called when done with char* that is returned from agk's functions. This is the message a lot of the functions show in the help pages "If you use this command in tier 2 you must delete the returned string with DeleteString when you are finished with it. "
SkinK4ir3
8
Years of Service
User Offline
Joined: 25th Aug 2015
Location:
Posted: 17th Jul 2023 00:40
I understand, but what would be a practical example in C++?
I'm very new to C++ so I have no idea how to do it correctly?
Dark Raven
9
Years of Service
User Offline
Joined: 27th Jul 2014
Location: United States
Posted: 17th Jul 2023 06:09
This post has been marked by the post author as the answer.
The following example is taken from the help site and converted to c++.
It was just a quick thing I ported for example. More thought should go into what you want to do.
But it compiled and ran and did what it was supposed to do. just keep in mind it just useless example code.
Honestly I've been utilitizing AGK's uString class for strings so when I call a function that returns a char*. I basically
use a temp string used to hold the returned char* and then save that to a uString object. I believe the uString allocates its own memory
and copies the contents to a new char* internal and when the uString object goes out of scope it automatically de-allocates the memory used.
Once the returns char* is save to the uString object I call agk:eleteString(tmpstr) to de-allocate the memory the library allocates.

char* example:



uString Example.

SkinK4ir3
8
Years of Service
User Offline
Joined: 25th Aug 2015
Location:
Posted: 17th Jul 2023 23:35
thanks it works .

Login to post a reply

Server time is: 2024-05-02 12:39:40
Your offset time is: 2024-05-02 12:39:40