如何测量 Arduino Mega 或 Due 上的代码消耗的内存或 RAM 量 [英] How to measure the amount of memory or RAM consumed by a code on Arduino Mega or Due

查看:37
本文介绍了如何测量 Arduino Mega 或 Due 上的代码消耗的内存或 RAM 量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我如何测量在 Arduino Mega 或 Due 上运行的特定代码消耗的 RAM.

Can anybody tell me how to measure the consumed RAM for a particular code running on Arduino Mega or Due.

推荐答案

这个问题有两种数字:全局静态使用当前运行时间.

There is two kinds of numbers to this question: Global static usage and current run time.

静态估计使用量可以通过添加以下行来确定(如果它不存在)

The static estimated usage can be determined by adding the following line to (if it does not already exist)

.\arduino-1.5.5\hardware\arduino\avr\boards.txt

.\arduino-1.5.5\hardware\arduino\avr\boards.txt

uno.upload.maximum_ram_size=2048

这将允许编译器在 IDE 的结果窗口中输出以下示例中的附加第二行

This then allows the compiler to output the additional 2nd line in the following example in the IDE's result window

Binary sketch size: 25,880 bytes (of a 32,256 byte maximum)
Estimated used SRAM memory: 990 bytes (of a 2048 byte maximum)

查看在任何给定点使用的内存量.包括当前使用的内存空间,只存在于函数和成员中.这包括 HEAP 等.我在代码中的特定点使用以下 MemoryFree 库 来揭示高水位.自述文件解释了如何通过打印保存不必要/无意使用的 RAM.

To see the amount of memory used at any given point. Including memory space currently in use, that exists while only in functions and members. This includes the HEAP and such. I use the following MemoryFree library at specific points in the code to reveal the high-water. The readme explains how to save unnecessarily/unintentionally used RAM by prints.

注意:虽然原始 Arduino IDE 1.0.5 的 board.txt 文件确实包含这些 ram_sizes,但它实际上并没有使用显示用法.最初的 Arduino IDE 1.5.5 以及 Arduino ERW 1.0.5 的功能(不受支持的分支).

Note: That while the original Arduino IDE 1.0.5's boards.txt files does contain these ram_sizes, it does not actually use display usage. Where the original Arduino IDE 1.5.5 does, along with Arduino ERW 1.0.5 does (an non-supported fork).

这篇关于如何测量 Arduino Mega 或 Due 上的代码消耗的内存或 RAM 量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆