Live data from Hacker News

Does memory leak? (1995)

groups.google.com

261–270 of 289 posts

Re: Does memory leak? (1995)

#261
post #40
post #17

Seems a bit unlikely to me. Intuitively, calculating how much memory a program will leak in the worst case should be at least as much effort as fixing the memory leaks. And if you actually calculated (as in, proved) the amount of leaked memory rather than just by empirically measuring it, there's no need to install double the amount of physical memory. This whole procedure appears to be a bit unbelievable. And we're…

The control flow graph will most likely be a loop doing PID; I think it could be statically analysed.

And why couldn't it be freed?

Re: Does memory leak? (1995)

#262

Earlier quoted context omitted.

> memory allocation will become a no-op (= bump allocation) No, that's a cache miss.

No, as memory is allocated linearly the cpu prefetchers will most likely keep the heap in cache.

No, in practice this is not true. You will also need to write out to memory all the newly allocated objects which you don't need anymore.

https://podcasts.apple.com/us/podcast/hidden-gc-bandwidth-co...

Re: Does memory leak? (1995)

#263

I once worked on an application which if failed even once meant considerable loss for the company including possible closure. By design, there was no memory management. The memory was only ever allocated at the start and never de-allocated. All algorithms were implemented around the concept of everything being a static buffer of infinite lifetime. It was not possible to spring a memory leak.

How did this work exactly? the program just never had to work on data greater than a certain statically known size? or did it process anything larger than that in chunks instead of mallocing a buffer of the necessary size?

Not necessarily. What this means, is you need to have a limit for every data structure in the application and have a strategy on how to either prevent the limit to ever be hit or how to deal when the limit is excercised.

Imagine a simple example of a webapp and number of user sessions.

Instead of the app throwing random errors or slowing down drastically, you could have a hard limit on the number of active sessions.

Whenever the app tries to allocate (find a slot) for a user session but it can't (all objects are already used), it will just throw an error.

This ensures that the application will always work correctly once you log in -- you will not experience a slowdown because too many users logged in.

Now, you also need to figure out what to do with users that received an error when trying to log in. They might receive an error and be told to log in later, they might be put on hold by UI and logged in automatically later or they might be redirected by loadbalancer to another server (maybe even started on demand).

When you start doing this for every aspect of application you get into situation where your application never really gets out of its design parameters and it is one of the important aspect to get an ultra stable operation.

Re: Does memory leak? (1995)

#264

Earlier quoted context omitted.

No, as memory is allocated linearly the cpu prefetchers will most likely keep the heap in cache.

No, in practice this is not true. You will also need to write out to memory all the newly allocated objects which you don't need anymore. https://podcasts.apple.com/us/podcast/hidden-gc-bandwidth-co...

How is that related to memory allocation costs? We are talking about the cost of obtaining a chunk of memory. The cost of actually creating an object is allowed to be much higher because constructors are allowed to execute any arbitrary code.

Just think about how expensive it would be to allocate a 3d vector consisting of 3 floats with malloc() 20000 times and then later deallocate it. Nobody is worrying about the cost of writing 3 floats to RAM. Everyone is worrying about the cost of malloc traversing a free list and it causing memory fragmentation in the process. Meanwhile the arena allocator would be at least as efficient as using an array of 3d vectors.

Re: Does memory leak? (1995)

#265

Earlier quoted context omitted.

Having worked on embedded systems for a decade at this point, the fact that we allow vendors to get away with providing ancient compilers and runtimes is shameful. We know that these old toolchains have thousands of documented bugs, many critical. We know how to produce code with better verification, but just don't push for the tools to do it.

Isn't the key part that these older systems have documented bugs? Or, to put it another way, if there's a wasp in the room (and there always is), I'd want to know where it is.

I think the idea is that you don't want a whole wasp nest. Just a bunch of stray wasps.

Re: Does memory leak? (1995)

#266

Earlier quoted context omitted.

> I can’t think of anything more important or critical than software that runs on a commercial airplane. Nuclear reactors?

Arguably, the existence of nuclear reactors which don't fail safe under any contemplated crisis is a hardware bug. It's possible to design a reactor that can be ruptured by a bomb or earthquake, which will then dump core into a prepared area and cool down. This kind of physics-based safety is obviously not possible for airplanes.

What triggers the core dump? Humans? Software? Are there detectors integrated into the walls?

Re: Does memory leak? (1995)

#267

Earlier quoted context omitted.

One TB of memory is actually quite expensive. And uses a fair bit of power.

Not at all compared to salaries. I mean just think about how many VMs you can buy for $200k-$500k/yr (total cost to the company of a senior engineer).

According to AWS you could only afford 10 instances each with 976GB of RAM for that salary (500k). If you were to do nothing but just buy the raw RAM it would cost you 50k. But you also need servers [0] to actually put the ram into. So it's probably closer to 70k. RAM isn't as cheap as you think.

[0] and a network and network admins and server admins and and and

Re: Does memory leak? (1995)

#268
post #74

Earlier quoted context omitted.

There was also a variant of it with the hard drives: building Windows produced a huge amount of object files, so the trick used was to use a whole hard disk (or a partition) for that. Before the next rebuild, deleting all the files would took far more time than a "quick" reformatting of the whole hard disk, so the later was used. (I am unable to find a link that talks about that, however). In general, throwing away a…

That's quite a clever solution, I doubt I would have thought of that! Windows has always been my daily drivers, and I really do like it. But I wish deleting lots of files would be much, much faster. You've got time to make a cup of coffee if you need to delete a node_modules folder...

What I have noticed is that the CLI commands like rm -rf are orders of magnitude faster than the file explorer on linux. When I want to remove and then copy 500 .wav files for my anki deck it takes a minute or longer in the file explorer. With rm -rf media.collection/ && cp -rf media.collection/ it doesn't even take a second.

Re: Does memory leak? (1995)

#269
post #151

Earlier quoted context omitted.

It's a valid question, but realistically if Costa Rica were invaded a number of countries would step in to help them. I love Costa Rica, it's one of the most beautiful countries I've been to and I do appreciate the political statement their making, but at the same time they're in a pretty unique situation. As for the ethics of working on weapons, I think there is a lot of grey when it comes to software. It tends to c…

In the last 40 years, Panama and Grenada were invaded, Honduras had a coup, Colombia had a civil war, Venezuela is currently having a sort of civil war, Nicaragua's government was overthrown by a foreign-armed terrorist campaign, and El Salvador's government sent death squads out to kill its subjects. Nobody stepped in to help any of them except Colombia. Why would Costa Rica be different? > Would I work on software…

Real weapons are not like that. They are expensive, they can fail to kill their target and they can also cause collateral damage. If death notes were as easy to obtain as guns there would clearly be an increase in homicides but that's not true with military missiles.

The Slaughterbots video is absolutely awful. First of all quadrocopters have an incredibly small payload capacity and limited flight time. A quadrocopter lifting a shaped charge would be as big as your head and have 5 minutes of flight. Simply locking your door and hiding under your bed would be enough to stop them. The AI aspect doesn't make them more dangerous than a "smart rifle" that shoots once the barrel points at a target.

Do you know what I am scared of? I am more scared of riot police using 40mm grenade launchers with "non-lethal" projectiles who are knowingly aiming them at my face even though their training clearly taught that these weapons should never be used to aim at someone's head. The end result is lost eyeballs and sometimes even deaths and the people who were targeted aren't just limited to those who are protesting violently in a large crowd. Peaceful bystanders and journalists who were not involved also became victims of this type of police violence. [0]

[0] https://www.thelocal.fr/20190129/france-in-numbers-police-vi...

Re: Does memory leak? (1995)

#270
post #231

Earlier quoted context omitted.

You're advocating throwing baby out with bathwater. Rust interops with C seamlessly, doesn't it? You don't have to throw out good code to use a better language or framework. C may be statically analyzable to some degree, but if Rust's multithreading is truly provable, then new code can be Rust and of course still use the tried and true C libraries. Disclaimer: I still haven't actually learned any Rust, so my logic is…

Rust's official documentation on FFI ( https://doc.rust-lang.org/nomicon/ffi.html ) recommends using an external crate 'libc' to facilitate even the minimal FFI functionality. This crate is not part of Rust itself. It is apparently maintained by some of Rust's developers, but again, this is not an official Rust component. To me this does not seem like the kind of mature design you would rely on for interoperability w…

Actually, Rust's std itself depends on that same libc crate, so it's a bit hard to say it's "not part of Rust itself".
Post reply on HN