# Issue with memory allocation

**URL:** <https://discuss.pynq.io/t/issue-with-memory-allocation/5184>\
**Category:** Support\
**Created:** [February 3, 2023, 7:18am UTC](https://discuss.pynq.io/t/issue-with-memory-allocation/5184 "2023-02-03T07:18:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbnyxrxp](https://avatars.discourse-cdn.com/v4/letter/d/e5b9ba/32.png) [@dbnyxrxp](https://discuss.pynq.io/u/dbnyxrxp)\
**Post date:** [February 3, 2023, 7:18am UTC](https://discuss.pynq.io/t/issue-with-memory-allocation/5184/1 "2023-02-03T07:18:22Z")

</div>

I’m using kria kv260 which has 4GB of ram and when I do `free -m`:

> total used free shared buff/cache available  
> Mem: 3906 327 3204 3 374 3417  
> Swap: 0 0 0

As you see I have 3GB free but when I try to allocate 2080MB it fails:

`allocate(shape=(272629760,), dtype=np.uint64)`

Error Message:

> RuntimeError: Allocate failed: 4294967295

I have 272629760 items which are 64bit so (272629760 \* 64) == 2080MB, But it fails to allocate.  
What am I missing?

---

<div class="post-metadata">

**Author:** ![marioruiz](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/marioruiz/32/2177_2.png) [@marioruiz](https://discuss.pynq.io/u/marioruiz)\
**Post date:** [February 3, 2023, 10:19am UTC](https://discuss.pynq.io/t/issue-with-memory-allocation/5184/2 "2023-02-03T10:19:09Z")

</div>

Hi @dbnyxrxp,

Welcome to the PYNQ community.

`allocate` needs Contiguous Memory Allocator (CMA) to work. In the KV260 the cma is configured to be around 1000M. You can check this with `cat /proc/cmdline`, you will see cma=1000M

If you request to `allocate` more than 1000M, it will fail as there is no enough contiguous memory memory available.

You may be able to change the kernel bootargs to get more cma memory. [https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/2363129857/Getting+Started+with+Certified+Ubuntu+22.04+LTS+for+Xilinx+Devices#[inlineExtension]Changing-the-Kernel-bootargs-Used-By-U-Boot](https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/2363129857/Getting+Started+with+Certified+Ubuntu+22.04+LTS+for+Xilinx+Devices#%5BinlineExtension%5DChanging-the-Kernel-bootargs-Used-By-U-Boot)

For further support on CMA, I would suggest the Xilinx forums.

Mario

---

<div class="post-metadata">

**Author:** ![dbnyxrxp](https://avatars.discourse-cdn.com/v4/letter/d/e5b9ba/32.png) [@dbnyxrxp](https://discuss.pynq.io/u/dbnyxrxp)\
**Post date:** [February 3, 2023, 11:51am UTC](https://discuss.pynq.io/t/issue-with-memory-allocation/5184/3 "2023-02-03T11:51:04Z")

</div>

I changed the args but still get the same error:

> root@kria:/# cat /proc/cmdline  
> cma=2800M earlycon root=LABEL=writable rootwait console=ttyPS1,115200 console=tty1clk\_ignore\_unused uio\_pdrv\_genirq.of\_id=generic-uio xilinx\_tsn\_ep.st\_pcp=4 cma=1000M quiet splash cma=2800M

> root@kria:/# cat /etc/default/flash-kernel  
> LINUX\_KERNEL\_CMDLINE=“quiet splash cma=2800M”  
> LINUX\_KERNEL\_CMDLINE\_DEFAULTS=“cma=2800M”

---

<div class="post-metadata">

**Author:** ![marioruiz](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/marioruiz/32/2177_2.png) [@marioruiz](https://discuss.pynq.io/u/marioruiz)\
**Post date:** [February 7, 2023, 10:16am UTC](https://discuss.pynq.io/t/issue-with-memory-allocation/5184/4 "2023-02-07T10:16:48Z")

</div>

Hi @dbnyxrxp,

I suggest you post your question on the Xilinx forums. Increasing CMA for the KV260 Ubuntu SD card image is outside of the scope of this forum.

Mario

---

<div class="post-metadata">

**Author:** ![dbnyxrxp](https://avatars.discourse-cdn.com/v4/letter/d/e5b9ba/32.png) [@dbnyxrxp](https://discuss.pynq.io/u/dbnyxrxp)\
**Post date:** [February 7, 2023, 1:43pm UTC](https://discuss.pynq.io/t/issue-with-memory-allocation/5184/5 "2023-02-07T13:43:45Z")

</div>

Thank you, even though I still face the issue but your answer got me on the track.

---

<div class="post-metadata">

**Author:** ![marioruiz](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/marioruiz/32/2177_2.png) [@marioruiz](https://discuss.pynq.io/u/marioruiz)\
**Post date:** [February 7, 2023, 3:29pm UTC](https://discuss.pynq.io/t/issue-with-memory-allocation/5184/6 "2023-02-07T15:29:22Z")

</div>


