# CPU and Memory limits

**URL:** https://drone.discourse.group/t/cpu-and-memory-limits/10993
**Category:** Drone Support
**Created:** [January 8, 2019, 6:56pm UTC](https://drone.discourse.group/t/cpu-and-memory-limits/10993 "2019-01-08T18:56:49Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![temi4root](https://avatars.discourse-cdn.com/v4/letter/t/dc4da7/32.png) [@temi4root](https://drone.discourse.group/u/temi4root)
#### Post date: [January 8, 2019, 6:56pm UTC](https://drone.discourse.group/t/cpu-and-memory-limits/10993/1 "2019-01-08T18:56:50Z")

</div>

Hi,  
How to limit memory and cpu for containers in drone 1.0.0-rc1?  
Thanks

---

<div class="post-metadata">

### Author: ![temi4root](https://avatars.discourse-cdn.com/v4/letter/t/dc4da7/32.png) [@temi4root](https://drone.discourse.group/u/temi4root)
#### Post date: [January 10, 2019, 5:00pm UTC](https://drone.discourse.group/t/cpu-and-memory-limits/10993/2 "2019-01-10T17:00:45Z")

</div>

Memory limit in .drone.yml  
resources:  
limits:  
memory: 600M

---

<div class="post-metadata">

### Author: ![azuruce](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/azuruce/32/4318_2.png) [@azuruce](https://drone.discourse.group/u/azuruce)
#### Post date: [November 19, 2019, 6:11pm UTC](https://drone.discourse.group/t/cpu-and-memory-limits/10993/3 "2019-11-19T18:11:02Z")

</div>

I hit memory problem. I need at least 4G virtual memory. Is the receipe above still working for docker runners?

The error I have is:  
465 CMakeFiles/xxx.make:1234: recipe for target ‘CMakeFiles/xxxe.cpp.o’ failed  
466 virtual memory exhausted: Cannot allocate memory  
467 make[2]: \*\*\* [CMakeFiles/xxx.o] Error 1

---

<div class="post-metadata">

### Author: ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)
#### Post date: [November 19, 2019, 6:20pm UTC](https://drone.discourse.group/t/cpu-and-memory-limits/10993/4 "2019-11-19T18:20:14Z")

</div>

The configuration syntax in this thread is used to _limit_ memory, not to allocate memory. Docker containers have access to unlimited memory by default and are only subject to limits imposed by the process manager or host machine operating system.

---

<div class="post-metadata">

### Author: ![azuruce](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/azuruce/32/4318_2.png) [@azuruce](https://drone.discourse.group/u/azuruce)
#### Post date: [November 19, 2019, 6:24pm UTC](https://drone.discourse.group/t/cpu-and-memory-limits/10993/5 "2019-11-19T18:24:46Z")

</div>

Hi how to debug this? Thanks for the help!  
when I run docker inspect \<container\_id\>, I saw like this:  
“Env”: [  
“DRONE\_MEMORY\_LIMIT=8000000000”,  
“DRONE\_PLATFORM\_OS=linux”,  
“DRONE\_PLATFORM\_ARCH=amd64”

---

<div class="post-metadata">

### Author: ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)
#### Post date: [November 19, 2019, 6:41pm UTC](https://drone.discourse.group/t/cpu-and-memory-limits/10993/6 "2019-11-19T18:41:56Z")

</div>

> [@On another topic](https://drone.discourse.group/t/3399/3):
>
> virtual memory exhausted

Is it possible you are running concurrent builds on the same machine and are exhausting memory resources? If your builds are resource intensive you should consider lowing the maximum number of pipelines that can run in parallel on a single machine, and install runners on multiple machines for increased parallelism.

also this might help if you are testing this on docker for mac / windows (this may not be relevant)

> <https://stackoverflow.com/questions/45049741/virtual-memory-exhausted-when-building-docker-image>

---

<div class="post-metadata">

### Author: ![azuruce](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/azuruce/32/4318_2.png) [@azuruce](https://drone.discourse.group/u/azuruce)
#### Post date: [November 19, 2019, 9:28pm UTC](https://drone.discourse.group/t/cpu-and-memory-limits/10993/7 "2019-11-19T21:28:39Z")

</div>

It turns out build passed on 8G memory machine. so it is somehow physical memory issue but reported as virtual memory. I don’t know why there is such a thing as physical memory is kind invisible to the docker machine
