What strings take up more memory and how to make my strings use less memory?

Simple question that I did not see anyone else ask.

Do strings on lower case “string” weight less than strings on higher case? “STRING” and what other characters make strings weight more?

2 Likes

What exactly do you mean by “weight”. I personally have never heard of a concept of weight for strings.

What makes a string take up more memory is how long the string is.
Each character in a string takes up the same amount of memory, reguardless of if it’s upper case or lower case.

1 Like

wait so how does a system knows if a string is higher case or lower case?

1 Like

It wouldn’t really make sense for either lowercase or uppercase strings to take up more memory or less memory.

Each character is a byte (ASCII) regardless if it’s upper or lowercase. Unicode characters use 2 bytes, I believe.

4 Likes

Thanks I was confused if I should be sending Higher case strings to the server every frame instead of lower case strings, but I see now that they take up more memory.

1 Like

This is a good question.

And @HugeCoolboy2007 is already giving you the main info.

But this was kinda mind-blowing to me too a long time ago, but text on computers is literally just numbers; it’s that simple!
We just all have to agree and remember that “A” = 65 and “a” = 97.

We just assigned each letter it’s own number a long long time ago and agreed to the standard.

1 Like

Ah so kinda like enums do?.

I recently have been optimizing my game’s netcode as it requires sending inputs to the server every frame and sending packets to clients every frame to update the worldstate as I use custom character replication and movement from chickynoid.

Anyways I also didnt knew strings were just number sequences.

1 Like

Also, Fun fact!

If you take a lower-case letter (in ASCII encoding), and “subtract 32” from it, you get the upper-case.

97 - 32 = 65
“A” - 32 = “a”

looks strange to put numbers and letters together, but that’s how it works.

1 Like

yup.

Enums are more or less doing a similar thing, in fact. You might as well equate all “stuff” on a computer to numbers. Computers store data in binary, and binary is literally just another way of representing numbers. It’s all numbers.

Enums are just another way of connecting certain “names” to numbers
like “East = 0” “South = 1” “West = 2” “North = 3”
You could pick any other numbers, but what we are doing is creating “Aliases” for numbers, so code can be easier to read.

Irrelevant comment but make you should be sending packets every OTHER frame (assuming it’s 60FPS). I believe that is the speed of Roblox’s network updating.

2 Likes

I dont really know how it’s exactly being sent, chickynoid just sends packets to the server as soon as it can and every frame or something like this.

The reason it sends stuff to the server every frame is because of it’s input system, by sending the inputs to the server every frame its possible to move the server characters with no problems

Characters and such should always be controlled by the client. Otherwise, there would be lag.

No they don’t and its the reason I chose this system, theres so much misinformation spread arround to the point I used poor techniques such as “anti cheats” for securing my game.

This solution is called server authoritative movement and it was invented back in the 90’s for quake.

Check out chickynoid if you are further interested: Chickynoid, server authoritative character replacement - Resources / Community Resources - DevForum | Roblox

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.