Page 1 of 1

statically allocated variables consume all available RAM

Posted: 13 January 2009, 1:58 AM
by ndudman
Hi

I'm just wanting to clarify i understand the error message correctly
  • Code: Select all

    Error: statically allocated variables consume all available RAM, see 'Option HeapSize'
Is it only variables declared as const which take up the RAM i.e

Code: Select all

const abc as String
Or are all declared program variables stored in RAM ? Unless specified with the Perm

I understand I should put more thought now into where/how to define different variables..and declare perm ones in their own file in a set order, along with a initialization sub.

Also if I get the above error message is it possible to still see a summary of usage per module to help identify the problematic code ?

Thanks
Neil

Re: statically allocated variables consume all available RAM

Posted: 13 January 2009, 8:44 AM
by dkinzer
ndudman wrote:Is it only variables declared as const which take up the RAM
On the contrary, all variables (other than Persistent variables and ProgMem variables) are assigned to RAM. Constants that you define are utilized at compile time, typically ending up in code space (Program Memory).
ndudman wrote:Also if I get the above error message is it possible to still see a summary of usage per module to help identify the problematic code ?
For VM devices, the .map file enumerates all of the variables defined by the program and shows their sizes and where they are defined. For native mode devices, the file most useful for that purpose may be the .sym file. Although it doesn't indicate where the variables are defined, it does enumerate them as shown in the excerpt below.

The first part of the .sym file shows the layout of Flash (Program Memory). The addresses that begin with 0080 indicate items that are in RAM while those that begin with 0081 are in EEPROM (Persistent Memory). You can deduce the size of any particular element by subtracting an item's (hexadecimal) address from that of the immediately following item. Variables defined in your code have the prefix zv_ while subroutines and functions defined in your code have the prefix zf_. Other variables and functions appearing in the .sym file come from the ZX Library code or the avr-gcc C runtime library.

Code: Select all

00800100 D __data_start
00800100 D heapEnd
00800102 B __bss_start
00800102 D __data_end
00800102 D _edata
00800102 B zv_myByteVar
00800103 B zv_myIntVar
0080012b B intTaskData
0080013d B txQPtrCom2
0080013f B rxQPtrCom2
00800141 B freeList
00800143 B heapLimit
00800145 B ioData1
00800156 B __bss_end
00800156 B txQueue
0080016f B rxQueue
008001a1 B zxd
008001d0 B seedPRNG
008001d4 B def_ubrr2x
008001d6 B com1Flags
008001d7 B com2Flags
008001d8 B ramEnd
008001da B rstFlags
008001db B _end