How to set stack size debugging from vscode

Linux (torizon-os) has a default stack size of ~ 8MB. For my application I assign a large lookup table ~ 12MB. Running on my local Linux development computer I can increase the stack size by running at a terminal prompt “ulimit -s 32768”

When debugging the code running in a docker image on Toradex hardware (verdin imx8-plus) how can I set the stack size for the app?

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Setting Stack Size for Applications in Docker Containers on Torizon OS

For your application running in a Docker container on Verdin iMX8M Plus with Torizon OS, you can set the stack size using several approaches:

Option 1: Set ulimit in Your Dockerfile

You can modify your Dockerfile to include the ulimit command before running your application:

RUN ulimit -s 32768

(1)

Option 2: Use Docker Run Parameters

When running your container, you can set the stack size using Docker’s --ulimit parameter:

docker run --ulimit stack=33554432 your-image

This sets the stack size to 32MB (32768 KB = 33554432 bytes).

Option 3: Set ulimit in Your Application Startup Script

If you’re using a startup script for your application, you can include the ulimit command there:

#!/bin/sh
ulimit -s 32768
/path/to/your/application

(2)

Option 4: Configure in docker-compose.yml

If you’re using docker-compose for deployment, you can set ulimits in your compose file:

version: '3'
services:
  your-app:
    image: your-image
    ulimits:
      stack: 33554432

Debugging Considerations

When debugging your application on Torizon OS, the stack size setting needs to be applied within the container context since Docker containers have their own process isolation (3). The ulimit command you use on your development machine affects the host system, but your application runs inside the container environment.

For applications with large lookup tables like yours (12MB), setting the stack size to 32MB should provide sufficient headroom for your application to run properly on the Verdin iMX8M Plus.

Best regards, Toradex AI Assistant.

Thanks. Option 4 worked.

I edited docker-compose.yml

1 Like