Size of Strings? (SOLVED)

Started by monkey0506, Thu 24/11/2005 05:35:35

Previous topic - Next topic

monkey0506

Just curious what the size of the String type is (in bits).

I have a struct that I set up with two String arrays (each of 200 units), and then I need about 30 - 35 thousand of those (roughly -- spread over 5 arrays).  The problem is that when I compile these arrays that my game (which I am using the Empty Game Template for ATM because I'm developing a new secret module), explodes in size.

80 MB is a bit much.  With those lines commented out it comes up to 1.31 MB.  I could technically cut the need back to about 16000 objects of the type, but then it still comes up to 25 MB.  But enough about that.  I'll figure that much out myself.  I was just wondering about the size of the String type.

Thanks.

Pumaman

Well, a String is a pointer type, which is 4 bytes. Plus of course if you actually set the string to something, the length of the string will be added to that.

Why do you need such a large number? Perhaps there might be a better way of doing what you're after?

GarageGothic

I must admit I still don't really understand the "inifinite length" of Strings and how it can be used for anything but storing data. Every time I try do anything with them, such as displaying or rawdrawing them, I still run into the old string limit?

Rui 'Trovatore' Pires

Slightly related to GG's post but not by much - I don't suppose removing the length limit of GUI labels is something you'd consider?
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

monkey0506

#4
Well...like I said it's supposed to be a secret (mostly because I don't want for my idea to fail and then have someone else come up with the same idea and get it to work), but I'm trying to manage some information regarding some things...erm...I really don't want to talk about it. ::)

If you really want to know, PM me and I'll discuss it privately.

But working out the math, I don't see how that even comes up to 80 MB.  Correct me if this is wrong, but what I've done is:

4 bytes / 1024 = 0.00390625 kilobytes
0.00390625 kilobytes / 1024 = 0.000003814697265625 MB
0.000003814697265625 MB * 32000 (approximation) = 0.1220703125 MB.

So why would my executable file be so huge? o_0

[EDIT:]

Well...there seems to have been a huge miscalculation on my part.  It turns out that I am asking for 20,640,000 Strings.  Wow that's a lot.  I'll have to...rethink this a bit.  That would explain the 80 MB.  I have to go hide now.

Pumaman

Quote from: GarageGothic on Thu 24/11/2005 12:40:44
I must admit I still don't really understand the "inifinite length" of Strings and how it can be used for anything but storing data. Every time I try do anything with them, such as displaying or rawdrawing them, I still run into the old string limit?

Although the string length limit has now been removed, a lot of other things in AGS were sort of built around the old limit -- therefore, it will take time for every feature to be updated to take unlimited length strings.


monkey_05_06: Yes, 20 million strings will need about 80 MB.

monkey0506

Yeah...I figured that much out.  So I'm going to implement a limit which will decrease that to about 8 MB.  It's still a lot...but, the limit is actually kind of small for the purpose methinks.  What can I do?  Ah well. :D

GarageGothic

Quote from: Pumaman on Fri 25/11/2005 19:42:02Although the string length limit has now been removed, a lot of other things in AGS were sort of built around the old limit -- therefore, it will take time for every feature to be updated to take unlimited length strings.

Yes, this was what I thought. I'd better stick to my textbreaking code then instead of waiting for this to be implemented. Thanks for the reply.

SMF spam blocked by CleanTalk