# Possibility to increase stack size?

**URL:** <https://forum.makecode.com/t/possibility-to-increase-stack-size/2996>\
**Category:** Help\
**Created:** [August 2, 2020, 5:49pm UTC](https://forum.makecode.com/t/possibility-to-increase-stack-size/2996 "2020-08-02T17:49:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [August 2, 2020, 5:49pm UTC](https://forum.makecode.com/t/possibility-to-increase-stack-size/2996/1 "2020-08-02T17:49:34Z")

</div>

Hello all,

I’m making a sandbox version of Sam Hogan’s Cell Machine. (See his youtube video at [https://www.youtube.com/watch?v=N-BbgqOjIqk](https://www.youtube.com/watch?v=N-BbgqOjIqk) - I highly recommend watching it!)

It’s going pretty well, actually, except that I keep getting stack overflows. Is it possible to increase the stack size? Or can I store other stuff in the heap to make room in the stack? Or does the SO mean that I would’ve run out of memory on a physical device? (PyGamer, not RPi0)

As always, if you find any bugs, please report them here. This is still in beta and oh dang it, found a bug. Got to go fix that…

Here’s the game:

> **[Sam Hogan's Game of Cells v0.4.1 BETA](https://arcade.makecode.com/86904-16379-73973-59760)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

  
Allows enemies to push other enemies without destroying them

> **Previous versions**
>
> [Sam Hogan’s Game of Cells v0.4 BETA](https://makecode.com/_XTKEiVHYd4mx)

**Instructions**

```auto
A Place the selected cell
B Cycle through all cells
Joystick/D-pad Move cursor around
Menu Start/pause/resume simulation

```

**Cells**  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/a/a8f704d12ee29844a0aa392551dfcd160b41b039.png)

```auto
1 - 4 Mover cells that move and push cells in the indicated direction
5 Pushable in all directions
6 & 7 Slides in the only indicated direction (= goes sideways and || goes up and down)
8 & 9 Rotate all 4 adjacent cells in indicated direction by 90 degrees each generation
10 - 13 Generator cells that clone the cell behind the arrow and push the cloned cell in the arrow's direction
14 Immobile cell that can not be pushed
15 Enemy cell that generates a point every time it is destroyed by pushing another cell into it
16 Used for removing cells while editing (Backspace basically)

```

And, as always, Github repository is here:

> **[UnsignedArduino/Sam-Hogans-Game-of-Cells](https://github.com/unsignedarduino/sam-hogans-game-of-cells)**
>
> Sam Hogan's Cell Machine, now on MakeCode Arcade! Contribute to UnsignedArduino/Sam-Hogans-Game-of-Cells development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [August 2, 2020, 7:58pm UTC](https://forum.makecode.com/t/possibility-to-increase-stack-size/2996/2 "2020-08-02T19:58:04Z")

</div>

Seems to be @darzu’s `move sprite by cols and rows`. Any idea why? (I might just be calling it way too much because `moveCell` is a recursive function that can run up to 20 (I think) layers deep in a single move because it might need to move other cells too)

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/c/c53eb0488a061cf8e7d2a0fbd13efddd446bd8b1.png)  
Oh, and if you need to make a stack overflow, here’s a simulation (shouldn’t be hard though):  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/f/fab1aee1301ac229a1e84474576aed08e5fd8795.png)

---

<div class="post-metadata">

**Author:** ![darzu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/darzu/32/1882_2.png) [@darzu](https://forum.makecode.com/u/darzu)\
**Post date:** [August 6, 2020, 4:21pm UTC](https://forum.makecode.com/t/possibility-to-increase-stack-size/2996/3 "2020-08-06T16:21:00Z")

</div>

Hey @UnsignedArduino, thanks for bringing this up. I’ve been swamped by a couple other things, but I’m planning on taking a look at this issue soon. Likely there’s some inefficiencies in the grid system that can be improved.

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [August 6, 2020, 4:34pm UTC](https://forum.makecode.com/t/possibility-to-increase-stack-size/2996/4 "2020-08-06T16:34:17Z")

</div>

Oh, I fixed it. I just return from the `moveCell` function if I’m trying to move a cell off the grid

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [August 6, 2020, 4:40pm UTC](https://forum.makecode.com/t/possibility-to-increase-stack-size/2996/5 "2020-08-06T16:40:49Z")

</div>

I think it’s my fault - I don’t know how to write recursive functions 🤦‍♂️

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [May 17, 2021, 4:59am UTC](https://forum.makecode.com/t/possibility-to-increase-stack-size/2996/6 "2021-05-17T04:59:23Z")

</div>

Also what is the stack size in Arcade? What about hardware?
