# Knowledge Base: Dealing with Allocator Mismatches with External Libraries

**URL:** <https://forums.unrealengine.com/t/knowledge-base-dealing-with-allocator-mismatches-with-external-libraries/1416830>\
**Category:** Platform & Builds\
**Tags:** unreal-engine\
**Created:** [November 24, 2023, 11:46am UTC](https://forums.unrealengine.com/t/knowledge-base-dealing-with-allocator-mismatches-with-external-libraries/1416830 "2023-11-24T11:46:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![UE\_Seb.Tho](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ue_seb.tho/32/1104173_2.png) [@UE\_Seb.Tho](https://forums.unrealengine.com/u/UE_Seb.Tho)\
**Post date:** [November 24, 2023, 11:46am UTC](https://forums.unrealengine.com/t/knowledge-base-dealing-with-allocator-mismatches-with-external-libraries/1416830/1 "2023-11-24T11:46:47Z")

</div>

Dealing with Allocator Mismatches when using external Libraries  
Unreal Engine uses its own allocators, a.k.a. new()/delete() implementation, such as mallocbinned2. Deleting memory that has been allocated outside of Unrea…  
  
[https://dev.epicgames.com/community/learning/knowledge-base/Eoyd/unreal-engine-dealing-with-allocator-mismatches-with-external-libraries](https://dev.epicgames.com/community/learning/knowledge-base/Eoyd/unreal-engine-dealing-with-allocator-mismatches-with-external-libraries)

---

<div class="post-metadata">

**Author:** ![LookWhatIDid](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LookWhatIDid](https://forums.unrealengine.com/u/LookWhatIDid)\
**Post date:** [February 25, 2024, 1:23am UTC](https://forums.unrealengine.com/t/knowledge-base-dealing-with-allocator-mismatches-with-external-libraries/1416830/2 "2024-02-25T01:23:50Z")

</div>

I could see tooling this. At least for Windows.  
First of all for all your modules `#undefine malloc`, then `#define malloc FMemory::Malloc(args)` kind of thing. And at the top header redirect new and delete to the allocators you list.

Make it a practice to not use standard names, use the `FMemory` ones across the board.  
Finally make a post build Python processing tool using LIEF or pefile module to parse the IAT of all built executable modules to capture any and all uses of CRT malloc, new, delete, etc.  
Build failure is the use of any of these problem APIs.  
Nip the problem in the bud before it manifests in crashes…

---

<div class="post-metadata">

**Author:** ![gamesmithe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@gamesmithe](https://forums.unrealengine.com/u/gamesmithe)\
**Post date:** [June 28, 2024, 9:27pm UTC](https://forums.unrealengine.com/t/knowledge-base-dealing-with-allocator-mismatches-with-external-libraries/1416830/3 "2024-06-28T21:27:58Z")

</div>

I am trying to build a library that can be used by unreal or other systems but I heavily rely on STL and build my components as a set of dlls for various reasons. How do I support allowing unreal developers to provide a custom allocator(Unreals allocator)?

---

<div class="post-metadata">

**Author:** ![Pyro0209](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pyro0209/32/711689_2.png) [@Pyro0209](https://forums.unrealengine.com/u/Pyro0209)\
**Post date:** [August 5, 2024, 12:44pm UTC](https://forums.unrealengine.com/t/knowledge-base-dealing-with-allocator-mismatches-with-external-libraries/1416830/4 "2024-08-05T12:44:46Z")

</div>

Hey @UE_Seb.Tho,  
does this also work for Android using .a files instead of .so?
