Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

code is too big #11541

glory666g started this conversation in Question - Community Help
Discussion options

Board

ESP32-S3

Device Description

ESP32-S3-Korvo-2

Hardware Configuration

no

Version

latest stable Release (if not listed below)

IDE Name

Arduino IDE

Operating System

Windows 11

Flash frequency

240MHz

PSRAM enabled

yes

Upload speed

115200

Description

I need to use a big unsigned char array,but the Arduino IDE compile not passed because the array is too big.How can i solve this problem?
The array has 4M elements.

Sketch

Bandwidth exhausted or memory limit exceeded

Debug Message

no

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
You must be logged in to vote

Replies: 1 comment

Comment options

I need to use a big unsigned char array,but the Arduino IDE compile not passed because the array is too big.How can i solve this problem?
The array has 4M elements.

Is it an immutable type of data, meaning that the bytes won't change along the execution of the application?
In such case it can be stored in the Flash, by declaring it as
const char Array[4 * 1024 * 1024] = { byte1, bytes2, ... , byte4194304 };

It is also necessary to correctly set the Partition Scheme to have an application partition that can store the firmware size plus the 4MB data.


Otherwise, if the data must be allocated to RAM, it shall go to a PSRAM sized to store such volume of data.
Declaration shall be something like:

char *bigArray = NULL;
void setup() {
 bigArray = (char *) malloc(4 * 1024 * 1024);
 if (bigArray == NULL) {
 log_e("Memory allocation in PSRAM has failed.");
 }
 // populating the array with sequence values
 for (uint32_t i = 0; i < 4 * 1024 * 1024; i++) {
 bigArray[i] = (char) i & 0xFF;
 }
}
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting triage Issue is waiting for triage
Converted from issue

This discussion was converted from issue #11538 on July 02, 2025 11:14.

AltStyle によって変換されたページ (->オリジナル) /