View unanswered posts | View active topics It is currently Sat Aug 23, 2014 2:04 pm






Reply to topic  [ 7 posts ] 
total available memory f. code, var declaration, stack, heap 
Author Message
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post total available memory f. code, var declaration, stack, heap
hi,
what is the maximum memory amount in RobotC for NXT of

total available memory,
for program code,
number of variable declarations,
stack,
and (maybe) heap?

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Sun Mar 23, 2008 7:59 am
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post 
Total variable memory is about 15K bytes.

Program memory is limited by the size of the flash file system. Have not tested programs beyond 25K bytes or so which is a really large program.

Stack size is sufficient to allow about 8 to 10 levels of function nesting. Recursive functions are not currently allowed.

No dynamic memory allocation so there is no heap.


Wed Mar 26, 2008 12:52 am
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 
hi,
thanks for reply, but what do you mean by:
"Stack size is sufficient to allow about 8 to 10 levels of function nesting"?
What does this particularly mean and how large is this?

Can you please tell me, if some day recursive functions will be allowed,
and further on, if dynamic memory allocation (heap) will be possible?.

Variable memory of about 15K bytes is rather small. Can this be enlarged?

And last, but not least, is there any limit to the number of variable declarations?

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Wed Mar 26, 2008 4:29 am
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post 
There's no limit on number of variables that I am aware.

Recursive functions are planned for later this year. Right now all variables are statically allocated (i.e. not on a stack). This is a common practice in many embedded systems; hence the restriction on no recursion as there is only one copy of procedure parameters and local variables.

The "task stack" size is a compile time constant and can be increased if needed. Currently it only holds function return addresses but the infrastructure is there for frame pointers and local variable storage. This is what's coming later this year.

15K is "enormous" memory size for a small embedded system. Some of the platforms that ROBOTC supports have only 256 bytes total for all user variables!


Wed Mar 26, 2008 1:41 pm
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 
I thought, the NXT had 256 kByte total memory.
Would be nice, if half of this was available for code, and the other half for variable stack, and heap.

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Wed Mar 26, 2008 5:26 pm
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post 
THe NXT has 256K bytes of flash (i.e. read only) memory and 64K bytes of RAM.

The size of the firmware load is somewhere in the 120K to 150K range. This is stored in flash. The remaining flash is for the file system.

ROBOTC variables are stored in RAM along with all sorts of other things like buffers for communications, etc.

Currently 15K of RAM is available for ROBOTC variables.

And yes. There is a big chunk of unused RAM that could be used for additional variable space with the current firmware. But its planned for things like the per task stack (recursive functions remember) which will tie up several KBytes (10 tasks at 512 byte stack each?) so it's unlikely the available memory for static variables will increase.


Thu Mar 27, 2008 2:04 am
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 
Dick Swan wrote:
Currently 15K of RAM is available for ROBOTC variables.

And yes. There is a big chunk of unused RAM that could be used for additional variable space with the current firmware. But its planned for things like the per task stack (recursive functions remember) which will tie up several KBytes (10 tasks at 512 byte stack each?) so it's unlikely the available memory for static variables will increase.


but 10 tasks at 512 byte stack = 5 kByte!
even 20 tasks (which is on MY wishlist!) will amount to just 10 kBytes.

plus 15 kByte current variable space = 20-25 kByte!

There still is a "chunk" of about 30 kBytes!

Can't you please increase the variable space by another 5 or 10 kBytes?

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Thu Mar 27, 2008 6:56 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.