How Do I Resolve Sandbox Task Terminations Caused by OOM Errors?
Symptom
When a task is running in the sandbox, the task is terminated unexpectedly and a message is displayed, indicating that the task is terminated due to an OOM error and asking you to increase the sandbox memory size or click Run to run the task outside the sandbox.
Cause Analysis
In the sandbox isolation environment, you can customize the CPU and memory specifications of the sandbox using the sandbox.json configuration file. If the actual memory usage during task execution exceeds the configured upper limit, the system forcibly terminates the task due to an out-of-memory (OOM) error, resulting in an execution failure. Common scenarios include:
- The amount of data to be processed is large, exceeding the current memory capacity.
- A program or service with high memory usage is running in the task.
- The sandbox memory specifications are too low to support the task load.
Solution
To address the preceding issue, you can refer to the two solutions below. The following table lists solution recommendations. Select a solution based on your actual situation.
| Comparison Item | Increasing Sandbox Memory Specifications | Switching to Non-sandbox Mode |
|---|---|---|
| Memory | Limited by the upper limit of sandbox specifications | No hard limit |
| Environment isolation | Sandbox isolation, secure and controllable | No isolation |
| Application scenario | Controllable task memory requirements, isolation required | High task memory requirements, secure and trusted content |
| Operation cost | Re-run required after configuration adjustment | One-click switch, effective immediately |
Solution 1 is recommended to resolve the issue while maintaining the security of sandbox isolation. If the memory requirements exceed the sandbox specifications or if tasks need to be quickly restored, solution 2 can be used.
Solution 1: Increasing Sandbox Memory Specifications
Change the value of resources.memory in the sandbox.json configuration file to adjust the maximum sandbox memory.
- Log in to CodeArts Agent IDE by referring to Quick Start.
- Click
in the upper right corner of CodeArts Agent IDE to open the settings page. - In the navigation pane on the left, choose Chats.
- Choose Agents > Terminal Command Running Mode > Custom Sandbox Settings and click Open File to open the sandbox.json file.
- Change the value of resources.memory in the sandbox.json file.
{ "resources": { "cpu": 50, "memory": 4 } } - Save the configuration file and run the task again.
If the OOM issue persists after the adjustment, check the task logic for potential memory leaks (for example, unreleased large objects or continuous data accumulation inside loops).
Solution 2: Switching to Non-sandbox Mode
Switch the agent's terminal command running mode to non-sandbox mode to remove sandbox memory restrictions.
- Log in to CodeArts Agent IDE by referring to Quick Start.
- Click
in the upper right corner of CodeArts Agent IDE to open the settings page. - In the navigation pane on the left, choose Chats.
- Under Agents, select Manual Running from the Terminal Command Running Mode drop-down list.
In manual mode, the agent sends a confirmation prompt to you before executing any command. You need to manually confirm it.
For security purposes, you are advised not to select Auto Running. In this mode, the agent bypasses all security checks and may perform high-risk operations without notification.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot