View unanswered posts | View active topics It is currently Fri Aug 22, 2014 12:52 am






Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Error: out of memory 
Author Message
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Error: out of memory
in my program I constantly get the same errors "out of memory", indifferent if I choose int or short, e.g.
Code:
//********************************************************************
const int MapSize=30;     
//********************************************************************
int Map[MapSize+1][MapSize+1];   
int xPrev[MapSize+1][MapSize+1]; 
int yPrev[MapSize+1][MapSize+1]; 
int F[MapSize+1][MapSize+1];   
int G[MapSize+1][MapSize+1]; 
int H[MapSize+1][MapSize+1];     
int List[MapSize+1][MapSize+1];   


the upper limit of MapSize always is close to 32 or 34, but I supposed if I always choosed short instead of int, the upper limit of these arrays could be larger (maybe twice as large).

Do int variables need the same memory compared to short?

_________________
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)}


Last edited by Ford Prefect on Wed Mar 12, 2008 6:04 pm, edited 2 times in total.



Wed Mar 12, 2008 12:28 pm
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 602
Post 
I think it may be the fact that you're declaring 6700+ variables technically (31*31*7+any other variables). It may be a namespace issue rather than physical memory available.

I don't recall off hand what the upper limit is for variables declarations... but I don't believe it's that high.

I'll take a look into this, however.

_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net


Wed Mar 12, 2008 4:59 pm
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post 
In ROBOTC, an "int" is 16-bits. This is common practice in many embedded systems that are memory constrained. Larger system may use a 32-bit default for "int". A short is 16-bits.

I recall that around 15000 bytes are available for variable declarations in ROBOTC so it is likely with other program declarations you may very well be running out of memory.

Also make sure you're using the latest version of ROBOTC. In an earlier version pointer and call by reference variables were sometimes being incorrectly allocated as the size of the "item" rather than a single pointer value. The code worked OK but it was wasteful on memory space.


Sat Mar 15, 2008 11:27 pm
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 
hello Dick,
thx for your reply.
In this case of my aStar algorithm and navigation programs it could be helpful if RobotC
char (signed byte)
declaration and conversiion to int (and back) worked without faults, because most of my map coordinates got a range from maximum -128 to 127.
But working with byte or ubyte or char causes many compiler and run time errors!

_________________
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 16, 2008 5:59 am
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 
@tfriez:
could you find out, why I get the out of memory error?

_________________
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:38 am
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post 
Send me your complete source code files at dickswan@sbcglobal.net and I will diagnose the problem. I cannot do it with simply code snippets.


Sun Mar 23, 2008 3:33 pm
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 
hello Dick,
I have already published the file here in the forum.
It's the A-star Algorithm, you'll find it under "Project discussion".
http://www.robotc.net/forums/viewtopic.php?p=1725&highlight=#1725

[EDIT]
The program works fine, but I just wanted to enlarge the Map
(mapsize now 30x30 (with an additional edge/margin, actually it's 31x31),
the limit for compilation is supposed to be close to 36x36,
but 50x50 (51x51) would be perfect).

Thx + regards
Helmut

_________________
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 3:45 pm
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 
In order to save memory, I even tried to change all variable declarations from
short varname
to
byte varname

(as far as possible);
but calculating with these byte values (which are supposed to be signed, as you wrote some time) always gives calculation errors and converting errors from byte to int and back converting errors from int to byte as well!!

So something in RobotC program seems to be quite "buggy"

_________________
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)}


Fri Mar 28, 2008 6:15 am
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post 
IN your code

Code:
const byte   MapSize=30;            // 30x30 Felder, je 30cm

short Map[MapSize+2][MapSize+2];    // besetzt=1 / frei=0;
short xPrev[MapSize+2][MapSize+2];  // Abszisse von Vorgaenger (x)
short yPrev[MapSize+2][MapSize+2];  // Ordinate von Vorgaenger (y)
short dPrev[MapSize+2][MapSize+2];  // Richtung  zu Vorgaenger (d= 0-7)
short F[MapSize+2][MapSize+2];      // gesamte Wege-Kosten F
short List[MapSize+2][MapSize+2];   // gehoert zu Liste:  undef=0 offen=1 geschlossen=2


Each array is 2048 bytes. 1024 elements x 2.

The output from the compiler V1.233 indicates:
Compile Statistics:
704 User Source file lines, 3,939 tokens
4,778 System Include file lines, 24,130 tokens
0 Errors, 19 Warnings, 0 Info Messages
12,919 Used memory locations (of 15000), 1 Tasks, 32 Procedures
6,692 Total code bytes, (after 936 bytes removed during optimization)

12,919 is about what's expected with six x 2K arrays plus other variables.


Fri Mar 28, 2008 7:19 am
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 
Thank you,
now that I know that 15000 bytes are the limt for variable space I understand the reason.

Change from short to byte makes runtime errors, so I need version 1.22 where the bugs have been fixed.

Where can I download version 1.22 ?

_________________
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)}


Fri Mar 28, 2008 10:17 am
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post 
Ford Prefect wrote:
Thank you,
now that I know that 15000 bytes are the limt for variable space I understand the reason.

I first posted about the 15K limit on this thread on March 16.


Fri Mar 28, 2008 10:34 am
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 
Thank you,
sometimes there were too many words in a reply.

But back to my answer:
where can I download version 1.22?
or when and where?

_________________
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)}


Fri Mar 28, 2008 10:57 am
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 602
Post 
By 5PM EDT today.

_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net


Fri Mar 28, 2008 11:17 am
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 
please, WHAT?

_________________
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)}


Fri Mar 28, 2008 2:10 pm
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 602
Post 
By 5:00pm (17:00) Eastern Daylight Time (-4 hour offset from GMT).

About an hour from now... if that's easier.

_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net


Fri Mar 28, 2008 3:55 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 16 posts ]  Go to page 1, 2  Next

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.