---
title: "AOSP source code build error: Virtual memory exhausted: Cannot allocate memory "
author: "allenshao"
date: "2014-01-02T15:47:09Z"
tags: []
categories: ["移动开发"]
slug: "aosp-source-code-build-error-virtual-memory-exhausted-cannot-allocate-memory"
draft: false
lastmod: "2014-01-02T15:48:27Z"
id: 1998360
url: "https://allenshao.iteye.com/blog/1998360"
---

Sometimes compiling certain things from source I've received a "virtual memory exhausted: Cannot allocate memory" error. The following is a quick tip to maybe allow gcc/libtool/make/whatever to finish their duty. 

**Change the user’s limits.**

```cmd

ulimit -n
```


and it is current showing as 1024. 
Increase limit from 1024 to 4084.

```cmd
ulimit -n 2048
```