NXT-G/NXC variable and memory allocation
Posted: 13 Dec 2011, 21:46
Hi,
as you can see, I ask a lot of question here since I work on new NXT-606 version. Thanks to all for your interest and your advices.
The first NXT-606 http://youtu.be/CilCI2kSXnA
I have to say I am very curious (for a long time) on how NXT deal with memory allocation. NXT-G and NXC have same firmware, so I think they act the same way. I have to say I'm a NXT-G user only.
To make real time operation, NXT-606 plays with a lot of variables which are faster to read than .txt files. I use .txt file to save song when I shutdown NXT.
Most of you should think I use array block to deal with hundreds of values but I'm not. Because access time could increase very much when reading end of array values in NXT-G. In fact it is faster to use text variable (is it what you call strings?), pointing values with TextSubset block.
My question is about variable and text variable allocation. When I'm working with very big text variable (>1000 characters) I found no way to understand how NXT deal with it.
It seems text variable size is limited by free memory. More the program is big, less the text variable can be big. I'm surprised because I never thought variables were stored in flash memory as programs. But it could be logical....
The other strange thing is the weird NXT behaviour when testing variable size limits.
When creating very big text variable, allocation seems to be non linear. For this I make little program that increase text variable character number and wait to NXT to stop cause of a memory error. NXT stop when it can't deal with text anymore.
When create 1 text variable: Variable size is limited to about 6272 characters
----------2-------------------------------------4464
----------3-------------------------------------3456
----------4-------------------------------------2816
Why this curve is non linear ? It seems these limits are subject to change depending on many things: program size, way program have been downloaded, line where task "create text" is called. in fact it seems to be very unpredictable and I found no logical way to understand it, what is very frustrating.
May be I'm wrong but I "feel" like a multiple memory allocation, perhap's NXT try to deal with 8 memories allocation and store text variables by cuting it in several parts... really I don't get it.
Does someone know about all that?
Thanks.
Peter.
as you can see, I ask a lot of question here since I work on new NXT-606 version. Thanks to all for your interest and your advices.
The first NXT-606 http://youtu.be/CilCI2kSXnA
I have to say I am very curious (for a long time) on how NXT deal with memory allocation. NXT-G and NXC have same firmware, so I think they act the same way. I have to say I'm a NXT-G user only.
To make real time operation, NXT-606 plays with a lot of variables which are faster to read than .txt files. I use .txt file to save song when I shutdown NXT.
Most of you should think I use array block to deal with hundreds of values but I'm not. Because access time could increase very much when reading end of array values in NXT-G. In fact it is faster to use text variable (is it what you call strings?), pointing values with TextSubset block.
My question is about variable and text variable allocation. When I'm working with very big text variable (>1000 characters) I found no way to understand how NXT deal with it.
It seems text variable size is limited by free memory. More the program is big, less the text variable can be big. I'm surprised because I never thought variables were stored in flash memory as programs. But it could be logical....
The other strange thing is the weird NXT behaviour when testing variable size limits.
When creating very big text variable, allocation seems to be non linear. For this I make little program that increase text variable character number and wait to NXT to stop cause of a memory error. NXT stop when it can't deal with text anymore.
When create 1 text variable: Variable size is limited to about 6272 characters
----------2-------------------------------------4464
----------3-------------------------------------3456
----------4-------------------------------------2816
Why this curve is non linear ? It seems these limits are subject to change depending on many things: program size, way program have been downloaded, line where task "create text" is called. in fact it seems to be very unpredictable and I found no logical way to understand it, what is very frustrating.
May be I'm wrong but I "feel" like a multiple memory allocation, perhap's NXT try to deal with 8 memories allocation and store text variables by cuting it in several parts... really I don't get it.
Does someone know about all that?
Thanks.
Peter.