简体   繁体   中英

Memory Allocation - Arduino

I'm new to this low level stuff. I'm currently learning arduino. I'm currently using an Arduino Mega 2560 and in our course we are practicing memory management. I'm a pro at memory management in pc but somehow I'm having crazy problems here in arduino. For instance:

The arduino have 8192B, I'm trying to overflow it with uint_16 so I made an array of 8192/16 which is 512. so I did

uint16_t A[512+1];

Well I expected that to cause an overflow.

What is wrong with my concept?

You seem to be confusing your bits for your bytes.

Assuming sizeof (uint16_t) is 2 on the Arduino, your array of 513 16-bit integers uses only 1026 bytes, which easily fits.

Also in Arduino when the memory is full, you don't get any error or warning. The microcontroller just restarts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM