SA-MP Forums Archive
Array elements memory usage question - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Array elements memory usage question (/showthread.php?tid=520345)



Array elements memory usage question - Riwerry - 18.06.2014

Hello guys, I'm not sure about this now. When I have array for example:
pawn Код:
new myarray[5];
What is size of one element? Is it 4 bytes, or am I wrong?
That means here: 5 * 4 = 20 bytes in memory it'll took? Please correct me if I'm wrong.


Re: Array elements memory usage question - Rittik - 18.06.2014

Код:
new myarray[5];
The number of slots in this array is 6 , such as 0,1,2,3,4,5.
So the conclusion is.
4*6 = 24 bytes


Re: Array elements memory usage question - Rittik - 18.06.2014

I think it should be

6(elements in an array)*8(One element's size) = 48 bits

****** ?


AW: Re: Array elements memory usage question - Nero_3D - 18.06.2014

Quote:
Originally Posted by Rittik
Посмотреть сообщение
I think it should be

6(elements in an array)*8(One element's size) = 48 bits

****** ?
That would be correct if the array consist of 6 "elements" (you should at least explain what you understand under elements) but either way it is incorrect

Quote:
Originally Posted by ******
Посмотреть сообщение
I suggest you read the link I posted as well.



Re: Array elements memory usage question - Rittik - 19.06.2014

Then what's the answer ****** ,I didn't get any useful information in that lang.pdf.
I still think it's 6*4 = 24 Bytes/Bits


Re: Array elements memory usage question - Ihateyou - 21.06.2014

Quote:
Originally Posted by Rittik
Посмотреть сообщение
Then what's the answer ****** ,I didn't get any useful information in that lang.pdf.
I still think it's 6*4 = 24 Bytes/Bits
array[5] = [0,1,2,3,4]

where the fck u get 6 from


Re: Array elements memory usage question - Rittik - 21.06.2014

@IHateYou : Yes you are right I guess, I was totally confused at that time of moment.

Now, The minimum size for char is 8 bit, the minimum size for short and int is 16 bit and for long it is 32 bit.

What do we use in pawno ?
new s=5; instead of int s=5;

So, if it stores an integer value then it should be.

Код:
5 elements*8 bits = 40bits //for integer and short
5 elements*16 bits = 80bits //for long.



Re: Array elements memory usage question - Rittik - 21.06.2014

But it's a C type language though.

How so ever.

Please tell me if this is correct or not.

Код:
5 elements * 32bits = 160bits //As per my knowledge of pawn.
If I am in-correct then please correct me.


Re: Array elements memory usage question - Swyft™ - 21.06.2014

Quote:
Originally Posted by Rittik
Посмотреть сообщение
But it's a C type language though.

How so ever.

Please tell me if this is correct or not.

Код:
5 elements * 32bits = 160bits //As per my knowledge of pawn.
If I am in-correct then please correct me.
string[5];

1,2,3,4,5....

It's not 32 bits, it's not 160 bits its fucking 5 bits. Jesus christ.


Re: Array elements memory usage question - Rittik - 21.06.2014

Quote:
Originally Posted by Swyft™
Посмотреть сообщение
string[5];

1,2,3,4,5....

It's not 32 bits, it's not 160 bits its fucking 5 bits. Jesus christ.
Can you prove it.