# Reading from socket causes massive amounts of memory allocation

**URL:** <https://discourse.julialang.org/t/reading-from-socket-causes-massive-amounts-of-memory-allocation/133206>\
**Category:** Performance\
**Tags:** question\
**Created:** [October 16, 2025, 1:42pm UTC](https://discourse.julialang.org/t/reading-from-socket-causes-massive-amounts-of-memory-allocation/133206 "2025-10-16T13:42:30Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![tt1234567](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tt1234567](https://discourse.julialang.org/u/tt1234567)\
**Post date:** [October 17, 2025, 1:11pm UTC](https://discourse.julialang.org/t/reading-from-socket-causes-massive-amounts-of-memory-allocation/133206/4 "2025-10-17T13:11:49Z")

</div>

I’m not sure it’s the same problem, but some time ago I tried without success to find a function in `Sockets` to read UDP packets which didn’t allocate each time it received data. All the receive functions seem to allocate a new array for each set of data received. See [How to pass a buffer to a C callback function?](https://discourse.julialang.org/t/how-to-pass-a-buffer-to-a-c-callback-function/87716) . I did manage to hack a `recv_into!` function but in the end I wrote the data access in C++ and called it via `CxxWrap`.

I did try creating a feature request [https://github.com/issues/created?issue=JuliaLang|julia|57029](https://github.com/issues/created?issue=JuliaLang%7Cjulia%7C57029)

---

_[View the full topic](https://discourse.julialang.org/t/reading-from-socket-causes-massive-amounts-of-memory-allocation/133206)._
