NIOS I memory usage

I've got a NIOS system running but have questions about memory usage (RAM). I've got 2 files that contain the issues. The 1st is the memory map (.mn) generated by the compiler and the 2nd is a memory dump captured using hyperterm. Before starting the CPU and capturing the memory dump, I filled RAM with AAAAs.

The two mysteries

(1) The map indicates we have a total ram of 8192 (I am using all decimal now) of which 5232 (about 63%) is allocated. That leaves about

2960 available. Included in the 5232 is a block of 1052 associated with malloc. We suspect this is used for local variable storage that exceeds the stack BUT what determines this block size?

Looking at our code, we cannot see where we need anywhere near this amount of RAM for local variable storage. How we make it smaller?

--- ouput of copmiler map file

00040000 A na_ext_ram 00040000 A nasys_usersocket_1 00040000 A nasys_vector_table 00040100 A _nasys_data_destination 00040100 A nasys_data_mem 00040100 A nasys_vector_table_end 00040100 D _data 00040100 D nS 00040104 D x 00040124 D y

... Deleted variable listing for clarity

00040abc D testStr 00040ad8 D RAMLimit 00040adc d inited.0 00040ae0 d inited.1 00040ae4 d impure_data 00040dd0 D _impure_ptr 00040dd4 D __mb_cur_max 00040dd8 d lc_ctype.0 00040de0 d last_lc_ctype.1 00040de8 D __malloc_av_ 000411f0 D __malloc_trim_threshold 000411f4 D __malloc_top_pad 000411f8 D __malloc_sbrk_base 000411fc D __malloc_max_sbrked_mem 00041200 D __malloc_max_total_mem 00041204 D __malloc_current_mallinfo 0004122c A __bss_start 0004122c A _nasys_uninitialized_storage 0004122c B _bss 0004122c D _edata 0004122c D _nasys_data_destination_end 0004122c b xAvg.48 00041234 b yAvg.49 0004123c b sAvg.50 00041244 B _nr_userisrtable 00041444 B atexit_func 00041448 B _main_return 0004144c B cwpUnderflowG 0004146c B errno 00041470 A _end 00041470 A _nasys_uninitialized_storage_end 00042000 A na_ext_ram_end 00042000 A nasys_data_mem_end 00042000 A nasys_stack_top

---------------- (2) When I run the program and dump the RAM, you can see that data (non AA values) occur through the first 5232 locations. Then there are some AA's followed by a large section of RAM with non AA's. In fact, it appears something is using another 2004 of RAM out of the available

2960. This wipes out our growth capability. What is using up this RAM and how do we prevent it?

Memory Dump-------------------

040000: 3641 000C 392F 000C 398A 000C 3641 000C 040010: 3641 000C 3641 000C 3641 000C 3641 000C 040020: 3641 000C 3641 000C 3641 000C 3641 000C

RAM contains mostly 0000s as expected.

040D10: 0000 0000 0000 0000 0000 0000 0AE4 0004 040D20: 0000 0000 0000 0000 0000 0000 0009 0001 040D30: 0000 0000 0000 0000 0000 0000 0D20 0004 040D40: 61FD 000C 621E 000C 624B 000C 6273 000C

Looks like this RAM contains the address of itself Probably a Malloc event.

040DF0: 0DE8 0004 0DE8 0004 0DF0 0004 0DF0 0004 040E00: 0DF8 0004 0DF8 0004 0E00 0004 0E00 0004 040E10: 0E08 0004 0E08 0004 0E10 0004 0E10 0004 040E20: 0E18 0004 0E18 0004 0E20 0004 0E20 0004 This pattern continues 0411C0: 11B8 0004 11B8 0004 11C0 0004 11C0 0004 0411D0: 11C8 0004 11C8 0004 11D0 0004 11D0 0004 0411E0: 11D8 0004 11D8 0004 11E0 0004 11E0 0004

Here starts a lot of Zeros..

0411F0: 0000 0002 0000 0000 FFFF FFFF 0000 0000 041200: 0000 0000 0000 0000 0000 0000 0000 0000 041210: 0000 0000 0000 0000 0000 0000 0000 0000

Continuing till

041440: 0000 0000 0000 0000 20FB 0008 0000 0000 041450: 0000 0000 0000 0000 0000 0000 0000 0000 041460: 0000 0000 0000 0000 0000 0000 0000 0000

An then untouched memory.

041470: AAAA AAAA AAAA AAAA AAAA AAAA AAAA AAAA 041480: AAAA AAAA AAAA AAAA AAAA AAAA AAAA AAAA 041490: AAAA AAAA AAAA AAAA AAAA AAAA AAAA AAAA 0414A0: AAAA AAAA AAAA AAAA AAAA AAAA AAAA AAAA

Till this which looks like stack usage

041780: AAAA AAAA 4141 4141 0041 0000 0003 0000 041790: FFFF FFFF FFFF FFFF 0000 0000 0031 0000 0417A0: 0300 0004 5C75 000C FF20 0000 0000 0000 0417B0: 0000 0000 0000 0000 56EC 000C AAAA AAAA 0417C0: AAAA AAAA AAAA AAAA AAAA AAAA AAAA AAAA

Up to the end of RAM or the Start of Stack.

041F40: 6DB0 3FE1 0000 0000 9800 40EA 5CBC 77C4 041F50: D662 3FEA 0000 0000 79B0 40F4 AAAA AAAA 041F60: AAAA AAAA AAAA AAAA AAAA AAAA AAAA AAAA 041F70: AAAA AAAA AAAA AAAA AAAA AAAA AAAA AAAA 041F80: AAAA AAAA AAAA AAAA AAAA AAAA AAAA AAAA 041F90: AAAA AAAA AAAA AAAA AAAA AAAA AAAA AAAA 041FA0: AAAA AAAA AAAA AAAA AAAA AAAA AAAA AAAA 041FB0: AAAA AAAA AAAA AAAA AAAA AAAA AAAA AAAA 041FC0: AAAA AAAA AAAA AAAA AAAA AAAA AAAA AAAA 041FD0: AAAA AAAA AAAA AAAA AAAA AAAA AAAA AAAA 041FE0: AAAA AAAA AAAA AAAA AAAA AAAA AAAA AAAA 041FF0: AAAA AAAA AAAA AAAA AAAA AAAA AAAA 0862

--------------------------------

Reply to
George
Loading thread data ...

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.