# LimeSuiteNG memory allocation error under Mac OS

**URL:** <https://discourse.myriadrf.org/t/limesuiteng-memory-allocation-error-under-mac-os/8576>\
**Category:** Lime Suite\
**Created:** [26 November 2024 02:34 UTC](https://discourse.myriadrf.org/t/limesuiteng-memory-allocation-error-under-mac-os/8576 "2024-11-26T02:34:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tkp](https://yyz2.discourse-cdn.com/flex034/user_avatar/discourse.myriadrf.org/tkp/32/4399_2.png) [@tkp](https://discourse.myriadrf.org/u/tkp)\
**Post date:** [26 November 2024 02:34 UTC](https://discourse.myriadrf.org/t/limesuiteng-memory-allocation-error-under-mac-os/8576/1 "2024-11-26T02:34:31Z")

</div>

This could be a bit outside of normal topics here, but I thought I would try anyway. I found that I am able to compile and create the LimeSuiteNG library under MacOS using CMAKE. I am able to compile the example programs (e.g. basicTX and dualRXTX), but when I run them they don’t make it past the streaming setup stage (device-\>StreamSetup(stream, chipIndex)), and give the following error: “Failed to configure settings: Failed to allocate memory”. Let me know if you have any ideas.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![ricardas](https://yyz2.discourse-cdn.com/flex034/user_avatar/discourse.myriadrf.org/ricardas/32/86_2.png) [@ricardas](https://discourse.myriadrf.org/u/ricardas)\
**Post date:** [26 November 2024 08:27 UTC](https://discourse.myriadrf.org/t/limesuiteng-memory-allocation-error-under-mac-os/8576/2 "2024-11-26T08:27:48Z")

</div>

Hi, could you provide more information:  
Which LimeSuiteNG version (git changeset) you used?  
What are the specs of your MacOS machine?  
Which LimeSDR device you are using?

---

<div class="post-metadata">

**Author:** ![tkp](https://yyz2.discourse-cdn.com/flex034/user_avatar/discourse.myriadrf.org/tkp/32/4399_2.png) [@tkp](https://discourse.myriadrf.org/u/tkp)\
**Post date:** [26 November 2024 18:04 UTC](https://discourse.myriadrf.org/t/limesuiteng-memory-allocation-error-under-mac-os/8576/3 "2024-11-26T18:04:38Z")

</div>

Thanks - it is a MacBook M3 Pro running OS 14.7.1. The SDRs I am using are LimeSDR Mini v2.4. I am not sure about the git changeset, but I built the library on Nov 3 and it made liblimesuiteng.0.2.0.dylib (actually liblimesuiteng.0.2-1.dylib, but that is just a link back to the previous one).  
I tried running the example programs that were built in cmake, and also re-made them in Xcode - same issue in each.  
Let me know if there is any other information you need or suggestions.  
Thanks!

---

<div class="post-metadata">

**Author:** ![ricardas](https://yyz2.discourse-cdn.com/flex034/user_avatar/discourse.myriadrf.org/ricardas/32/86_2.png) [@ricardas](https://discourse.myriadrf.org/u/ricardas)\
**Post date:** [26 November 2024 18:49 UTC](https://discourse.myriadrf.org/t/limesuiteng-memory-allocation-error-under-mac-os/8576/4 "2024-11-26T18:49:38Z")

</div>

Unfortunately I don’t have access to Apple machines, so I can’t debug it directly. Based on your description and clang compiler nuances, I suspect the fault is due to aligned memory allocation failure.  
I’ve created a branch `"macos-memory-issue"` with that removed, I’d appreciate if you could test it.  
Inside LimeSuiteNG directory do `git pull` then `git checkout macos-memory-issue`, then build as usual.

---

<div class="post-metadata">

**Author:** ![sergey](https://yyz2.discourse-cdn.com/flex034/user_avatar/discourse.myriadrf.org/sergey/32/4871_2.png) [@sergey](https://discourse.myriadrf.org/u/sergey)\
**Post date:** [26 November 2024 21:01 UTC](https://discourse.myriadrf.org/t/limesuiteng-memory-allocation-error-under-mac-os/8576/5 "2024-11-26T21:01:44Z")

</div>

Hi @ricardas.

The issue is caused by TRXLooper requesting incompatible allocation size and alignment. In my case it is this call: `mTx.memPool = std::make_unique<MemoryPool>(1024, upperAllocationLimit, 4096, name)`. The allocation size is 8232, and alignment is 4096.

From quick reading the doc [std::aligned\_malloc](https://en.cppreference.com/w/cpp/memory/c/aligned_alloc) I’m not sure if that’s not supported at all, or not supported on some platforms.

Using the `macos-memory-issue` branch or aligning the allocation size to the 4096 boundary solves the crash.

---

<div class="post-metadata">

**Author:** ![tkp](https://yyz2.discourse-cdn.com/flex034/user_avatar/discourse.myriadrf.org/tkp/32/4399_2.png) [@tkp](https://discourse.myriadrf.org/u/tkp)\
**Post date:** [26 November 2024 21:12 UTC](https://discourse.myriadrf.org/t/limesuiteng-memory-allocation-error-under-mac-os/8576/6 "2024-11-26T21:12:41Z")

</div>

Thanks for the response(s) - yes, the issue is now solved and I can make the library and run the examples without problem.  
Thanks for your help!

---

<div class="post-metadata">

**Author:** ![ricardas](https://yyz2.discourse-cdn.com/flex034/user_avatar/discourse.myriadrf.org/ricardas/32/86_2.png) [@ricardas](https://discourse.myriadrf.org/u/ricardas)\
**Post date:** [26 November 2024 21:58 UTC](https://discourse.myriadrf.org/t/limesuiteng-memory-allocation-error-under-mac-os/8576/7 "2024-11-26T21:58:36Z")

</div>

Thanks for verifying. Indeed according to docs, the allocation size has to be multiple of alignment, otherwise depending on compiler version it’s undefined behaviour.  
I’ve pushed the fix into main `develop` branch.

---

<div class="post-metadata">

**Author:** ![sergey](https://yyz2.discourse-cdn.com/flex034/user_avatar/discourse.myriadrf.org/sergey/32/4871_2.png) [@sergey](https://discourse.myriadrf.org/u/sergey)\
**Post date:** [27 November 2024 08:19 UTC](https://discourse.myriadrf.org/t/limesuiteng-memory-allocation-error-under-mac-os/8576/8 "2024-11-27T08:19:57Z")

</div>

Lovely! I’ve checked the `develop` branch and the issue is indeed solved.
