# Memory Tools in MakeCode Arcade

**URL:** <https://forum.makecode.com/t/memory-tools-in-makecode-arcade/499>\
**Category:** Arcade\
**Created:** [August 30, 2019, 3:03pm UTC](https://forum.makecode.com/t/memory-tools-in-makecode-arcade/499 "2019-08-30T15:03:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mileswatson](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/mileswatson/32/333_2.png) [@mileswatson](https://forum.makecode.com/u/mileswatson)\
**Post date:** [August 30, 2019, 3:03pm UTC](https://forum.makecode.com/t/memory-tools-in-makecode-arcade/499/1 "2019-08-30T15:03:21Z")

</div>

Hi all,

Are there any plans to implement any tools for visualizing memory usage in the Arcade Simulator? Most of the devices arcade targets have quite limited RAM, and so it would be nice to know the memory footprint of the program without having to leave the simulator.

This could also be extended to a profiler-like tool, so that we can see which categories (e.g. sprites, tiles, arrays) are taking up the most memory, in order to optimize. The tools do not need to be exact, just enough to give a decent estimate of which area is the problem.

Even if the memory allocation is not identical between the browser and the device, this would be a useful indication of any memory bloat.

Thanks,

- Miles

---

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [August 31, 2019, 3:22am UTC](https://forum.makecode.com/t/memory-tools-in-makecode-arcade/499/2 "2019-08-31T03:22:13Z")

</div>

I agree, Miles, that this would be a nice feature.

The only place where I’ve run into memory problems is when dynamically creating images. Static images - or any other static data in your application, for that matter - are compiled into the “executable” and are not much of a concern. However, when you do something like `image.create(screen.width, screen.height)`, that image is stored on the heap, which is _extremely_ limited on current hardware devices. I’ve found that if you try to create more than two full-screen images, you’ll trip one of the out-of-memory errors on hardware.

It’s not much of an issue when creating objects or even small sprites. You shouldn’t run into memory issues even when creating a couple of hundred objects or a couple of dozen sprites.  
Full-screen images, though, occupy a lot of space.

Joey (@jwunderl) put together a few pointers on dealing with the limited memory of hardware.

> **[Errors on Hardware](https://arcade.makecode.com/hardware/errors)**
>
> When developing games, you might run into bugs that cause your game to crash.
> In the browser, these errors can be identified by using the debugger
> or by reading the messages displayed along with the error.

See the section on error **021: Out of memory: too many objects**.

---

<div class="post-metadata">

**Author:** ![mmoskal](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/mmoskal/32/20_2.png) [@mmoskal](https://forum.makecode.com/u/mmoskal)\
**Post date:** [August 31, 2019, 4:22am UTC](https://forum.makecode.com/t/memory-tools-in-makecode-arcade/499/3 "2019-08-31T04:22:29Z")

</div>

This indeed sounds like a good idea, but it will require quite some work. I’ll take a look in the coming month or two.

---

<div class="post-metadata">

**Author:** ![mmoskal](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/mmoskal/32/20_2.png) [@mmoskal](https://forum.makecode.com/u/mmoskal)\
**Post date:** [November 26, 2019, 12:09am UTC](https://forum.makecode.com/t/memory-tools-in-makecode-arcade/499/4 "2019-11-26T00:09:58Z")

</div>

To follow up, for some time there’s a low-level support for tracking memory leaks, see here [https://makecode.com/js/profiling#profiling-memory](https://makecode.com/js/profiling#profiling-memory)

It uses JS console.

Most likely only in beta beta.

---

<div class="post-metadata">

**Author:** ![kjw](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@kjw](https://forum.makecode.com/u/kjw)\
**Post date:** [July 18, 2020, 12:10pm UTC](https://forum.makecode.com/t/memory-tools-in-makecode-arcade/499/5 "2020-07-18T12:10:06Z")

</div>

There’s some recent activity in this area in the CircuitPython world:

- [YouTube: Adafruit Industries: Deep Dive w/Scott: Allocation Optimization](https://www.youtube.com/watch?v=iQQLMhxAR34&t=39m30s) - this is long and “features” the Cloudflare outage but I’ve linked to where an example starts
- [GitHub: adafruit/circuitpython: Add `memorymonitor` for memory allocation debugging #3163](https://github.com/adafruit/circuitpython/pull/3163)
