How exactly does Godot allocate memory in a PoolStringArray?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Orgull

I am trying to find out how much RAM one of the arrays I would need will take up so I ran a test.

var test = PoolStringArray(); test.resize(134217728); test.fill("aa");

When I ran it, both the Godot profiler and Task Manager said the program was using just over 1GB RAM. When I changed the string (in “fill”) from a two-character string to a sixteen-character string… it said 1GB RAM. When I put in a two-THOUSAND character string (containing a mix of random characters) just to see… it said 1GB RAM.

Why would a 134 million element array containing two-character long strings take up 1GB when two characters is only two bytes? Shouldn’t it be only 256 MB?

Why would a 134 million element array containing two-THOUSAND character long strings take up 1GB? Shouldn’t it be 250 GB?

What am I missing? Thank you in advance! (Sorry I am very new at this and coding is really hard for me to understand)