ESP32 Compiler Error "DRAM segment data does not fit"

Hello,
Just starting out on ESP32 and have some DOIT DEVKIT1 ESP32 WROOM-32 boards.
I have a Serial to WiFi Modem ESP NOW project working and now just starting out on my 2nd project that needs a number of 40kbyte 2D arrays.
App A compiler OK but App B fails with compile error "DRAM segment data does not fit"
After compile of App A report is:
Global variables use 102816 bytes (31%) of dynamic memory, leaving 224864 bytes for local variables. Maximum is 327680 bytes.
Which means I have loads more space for LocalMapThree[][]
Any ideas please, many thanks in advance IMK

--------------- Begin App A ---------------------
// Include Libraries
#include <esp_now.h>
#include <WiFi.h>
#include <esp_wifi_types.h>
#include <esp_wifi.h>

unsigned char LocalMapOne[201][201];
unsigned char LocalMapTwo[201][201];

void setup()
{ // put your setup code here, to run once:
LocalMapOne[0][0] = 0;
LocalMapTwo[0][0] = 0;
}

void loop()
{ // put your main code here, to run repeatedly:
}
--------------- End App A ---------------------

--------------- Begin App B ---------------------
// Include Libraries
#include <esp_now.h>
#include <WiFi.h>
#include <esp_wifi_types.h>
#include <esp_wifi.h>

unsigned char LocalMapOne[201][201];
unsigned char LocalMapTwo[201][201];
unsigned char LocalMapThree[201][201];

void setup()
{ // put your setup code here, to run once:
LocalMapOne[0][0] = 0;
LocalMapTwo[0][0] = 0;
LocalMapThree[0][0] = 0;
}

void loop()
{ // put your main code here, to run repeatedly:
}
--------------- End App B ---------------------

There may exist a limit in static RAM allocation, also stack size. Try to locate and check related values in your board or project settings.

Have you enabled extended compiler diagnostics?

Seems to be an ESP32 RAM (multiple types) architecture issue.
malloc seems to works, as each malloc report's OK
Many thanks for the reply IMK

char pLocalMapOne = (char)malloc( 201 * 201 );
if( pLocalMapOne )
Serial.println("Malloc pLocalMapOne Ok");
else
Serial.println("Malloc pLocalMapOne Failed");

char pLocalMapTwo = (char)malloc( 201 * 201 );
if( pLocalMapTwo )
Serial.println("Malloc pLocalMapTwo Ok");
else
Serial.println("Malloc pLocalMapTwo Failed");

char pLocalMapThree = (char)malloc( 201 * 201 );
if( pLocalMapThree )
Serial.println("Malloc pLocalMapThree Ok");
else
Serial.println("Malloc pLocalMapThree Failed");

You see the modified display of your code?
That's why <CODE> should be used to present code. You can edit your post, select the code and click <CODE>.

Hello DrDiettrich
I find this abomination of so called standard C/C++ layout ugly and very difficult to read and follow as bits of code are floating all over the page and if( ! is easier to read with my tired old eyes than if (! as (! tend to visually merge where ( ! is much clearer.
That is why i like the style that I have been using since my days doing C on a VAX/VMS in 1980 something . I accept your tip and many thanks IMK, but in my mind we are teaching bad behaviour as the other I accidentally hit the format function in IDE2 (which I love) and it put the ;
of a do while() half way down the page??. Madness! :slight_smile:

Did the edit code function for you and it didn't work, There is a God! :slight_smile:

The layout is not the big problem, instead it's all the suppressed stars:

should read
char *pLocalMapOne = (char*)malloc( 201 * 201 );

I wonder how long the first usable IDE2 will take :frowning:

You did not edit any of your posts. Try again with post #3.

Didn't have C on our pdp's. Hit C on my Atari ST with horrible compilers. Wrote everything in GfA Basic on the ST until Visual Basic and Delphi was available on a PC.

Hello DrDiettrich
point taken about the '*' for some reason they seemed to disappear, I love magic tricks just someone people don't seem to understand when to use them. There's another forum I post to where they insist on four spaces before and code. Oh well "different strokes for different folks", life is wonderful :-). Moring I have had includes "The lady across the road doesn't understand boyle's law when it comes to the static pressure in her combi boiler"
Thanks for the help, IMK who's heading into garden to get the summer flower beds laid :slight_smile:
PS My first PC C was using MS Quick C under PC DOS 3.3 and token ring networking

I did edit the post and tried to use the Preformatted text toolbar button <CODE/>, or the backtick `.
There is -------------------------- NO SUCH TOOL ON THE TOOL BAR --------------------------------

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.