String Memory Usage
#1

I am trying to figure out which method of using a string would use the least amount of memory.

So basically, my string that holds my list of commands that are displayed in a dialog by the command "/cmds" is currently over 800 characters long. With a string that large my original thinking was that I should make it a global string and store the list of commands on initialization so they are simply accessible by everyone from only one variable.

Now I am starting to think in reverse and I am wondering if it eats up more memory to have that one large string sitting unused until someone requests the command dialog but I'm not sure if creating the string every time someone uses "/cmds" would use more or less memory, because if multiple people do that command at the same, I now have several large strings being stored.

What I'm wondering is if once the string is created in command and shown, is it then destroyed as soon as the command finishes, or is it still in memory until the dialog closes? If it's destroyed then I believe that it would use less memory.
Reply
#2

I'm not that worried, I was just wondering if there was big difference in memory usage.

If it was really such an inconvenience for you to answer this, you too could have just "got on with it"...
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
If it was inconvenient for me to answer - I wouldn't have!
Quote:
Originally Posted by admiralspeedy
Посмотреть сообщение
I'm not that worried, I was just wondering if there was big difference in memory usage.

If it was really such an inconvenience for you to answer this, you too could have just "got on with it"...
Quote:
Originally Posted by ******
Посмотреть сообщение
It is destroyed. Also, 800 characters is less than your post asking about your 800 character string! Why are you so worried about the memory requirements of that tiny TINY thing when the browser you are viewing this answer on uses VASTLY more memory and you don't bat an eyelid?

I truly don't understand why people around here are so obsessed with tiny memory changes, to the point that they waste this much time asking instead of just getting on with it.
Quote:
Originally Posted by admiralspeedy
Посмотреть сообщение
I am trying to figure out which method of using a string would use the least amount of memory.

So basically, my string that holds my list of commands that are displayed in a dialog by the command "/cmds" is currently over 800 characters long. With a string that large my original thinking was that I should make it a global string and store the list of commands on initialization so they are simply accessible by everyone from only one variable.

Now I am starting to think in reverse and I am wondering if it eats up more memory to have that one large string sitting unused until someone requests the command dialog but I'm not sure if creating the string every time someone uses "/cmds" would use more or less memory, because if multiple people do that command at the same, I now have several large strings being stored.

What I'm wondering is if once the string is created in command and shown, is it then destroyed as soon as the command finishes, or is it still in memory until the dialog closes? If it's destroyed then I believe that it would use less memory.
Instead of using string you can divide in some groups
see here: https://sampwiki.blast.hk/wiki/How_to_Create_a_Dialog
Reply
#4

Quote:
Originally Posted by SturtIndia
Посмотреть сообщение
Instead of using string you can divide in some groups
see here: https://sampwiki.blast.hk/wiki/How_to_Create_a_Dialog
I don't think you understand my question. It's a message box dialog and I use strcat and a string. If you try and add 800 characters to the ShowPlayerDialog function with \n separating them, you will likely get an error because of length and it will be one huge and ugly line of text that is hard to add to or edit.
Reply
#5

If the lines in your ShowPlayerDialog function is too huge, I'll suggest you to make two dialogs linked together as "Page 1" and "Page 2".That would be better.
Reply
#6

Quote:
Originally Posted by codectile
Посмотреть сообщение
If the lines in your ShowPlayerDialog function is too huge, I'll suggest you to make two dialogs linked together as "Page 1" and "Page 2".That would be better.
Or I cold just format a string like I'm doing.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)