using large number of arrays causes memory run time errors

Hi,

I have an array of 100 (should be more) structures that hold 100 arrays of int (again, shoul be more).
it compiles okay but reminds me that the memory is high.
when I run the code (on UNO) I see that it does not run correctly - memory leaks?

How do I use this type of data correct?
Declaration and usage?

Many thanks

This is a sample of the code:

//This is at the top

typedef struct {
int myStructArray[100]; //the steps of the story
int myStructFlag;
} myStruct;

//This is in setup section

myStruct myStructCellArray[100];

//This is in one of the function called from the main loop - called once

myStructCellArray[0].myStructArray[0] = 1;
myStructCellArray[0].myStructArray[1] = 3;
myStructCellArray[0].myStructArray[2] = 5;
myStructCellArray[0].myStructArray[3] = 6;
...
...

myStructCellArray[0].myStructArray[99] = 6;
...
...
myStructCellArray[1].myStructArray[0] = 1;
myStructCellArray[1].myStructArray[1] = 3;
myStructCellArray[1].myStructArray[2] = 5;
myStructCellArray[1].myStructArray[3] = 6;
...
...
myStructCellArray[1].myStructArray[99] = 4;
...
...

myStructCellArray[99].myStructArray[97] = 5;
myStructCellArray[99].myStructArray[98] = 4;
myStructCellArray[99].myStructArray[99] = 100;

Tziki:
I have an array of 100 (should be more) structures that hold 100 arrays of int (again, shoul be more).

How many bytes of memory does that require? How many bytes of memory does an Uno have?

UNO has 32 K
An integer holds 1 byte - so it should be around 10 k for the arrays

32K program memory, 2K data memory in the Uno.

The default integer on Arduino takes 2 bytes.

Tziki:
UNO has 32 K
An integer holds 1 byte - so it should be around 10 k for the arrays

The Uno has 32K of flash but only 2K of RAM.

Your structure is 202 bytes (sizeof(int)*100 + sizeof(int); an array of 100 of them is asking for 20,200 bytes.

Thanks,

How ever it does not work on 5050 arrays and even with 2020.

I thoght (my bad) that it uses the flash memory automaticly - can you refer me to howw to use the flash memory?

Look up the PROGMEM keyword and related topics.

Thank you!!
Will do.

Are there other simpler ways?
Is there a include file that simplifies the issue?

To store numerical data in program memory, you need to use the PROGMEM macro/keyword, and get the data back out using specific functions for access.

A short cut for certain operations, like Serial.print(), is to use the F macro to store the string in program memory:

Serial.println(F("This is a test"));

Thank you!!

@Tziki

Be aware that you can't modify data stored in flash. If there is a need for that, flash is the wrong choice.