Live data from Hacker News

Does memory leak? (1995)

groups.google.com

161–170 of 289 posts

Re: Does memory leak? (1995)

#161
post #76

Earlier quoted context omitted.

But that is a case where you have several filenames and you want to concatenate the files . The work you're using cat to do is to locate and read the files based on the filename. If you already have the data stream(s), cat does nothing for you; you have to choose the order you want to read them in, but that's also true when you invoke cat. This is the conceptual difference between pipeline | cat # does nothing and pi…

pipeline | cat # does nothing This is actually re-batching stdin into line-oriented write chunks, IIRC. If you write a program to manually select(2) + fread(2) from stdin, then you’ll observe slightly different behaviour between e.g. dd if=./file | myprogram and dd if=./file | cat | myprogram On the former, select(2) will wake your program up with dd(1)’s default obs (output block size) worth of bytes in the stdin ke…

> Also, if you have multiple data streams, ...then cat(1) won’t even help you there.

I've been thinking about this more from the perspective of reusing code from cat than of using the cat binary in multiple contexts. Looking over the thread, it seems like I'm the odd one out here.

Re: Does memory leak? (1995)

#162

Earlier quoted context omitted.

So I kind of disagree with the idea that arenas are all about deallocation at once. There's other contexts where you have separate arenas but don't plan on deallocating in blocks, mainly around when you have memory with different underlying semantics. "This block of memory is faster, but not coherent and needs to be manually flushed for DMA", "this block of memory is fastest but just not DMA capable at all", "there's…

Those aren't arenas. I'm inclined to agree with Wikipedia's definition, which does emphasise deallocation all at once: > A region, also called a zone, arena, area, or memory context, is a collection of allocated objects that can be efficiently deallocated all at once.

I mean, wiki uses zone and region here as synonyms, so according to wiki that definition applies just as much. And yet:

https://www.kernel.org/doc/gorman/html/understand/understand...

Like, as a embedded developer, these concepts are used pretty much every day. And in a good chunk of those, deallocation isn't allowed at all, so you can't say that the definition is around deallocation at once.

You can also see how glibc's malloc internally creates arenas, but that's not to deallocate at once, but instead to manage different locking semantics. https://sourceware.org/glibc/wiki/MallocInternals

Re: Does memory leak? (1995)

#163

Earlier quoted context omitted.

You’ll find that for very serious, industrial applications, a conservative mindset prevails. C may not be trendy at the moment, but it powers the computing world. Its shortcomings are also extremely well known and also statically analyzable. Also, think about when flight software started being written. Was Rust an option? And once it came out, do you expect that programmers who are responsible for millions of people’…

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/C interop still has major challenges. It isn't seamless.

Re: Does memory leak? (1995)

#164
post #85

Earlier quoted context omitted.

I'm always fascinated about software running on hardware-restricted systems like planes, space shuttles, and so on. Where can someone (i.e., in my case a software engineer who's working with Kotlin but has used C++ in his past) read more about modern approaches to writing embedded software for such systems? I'm asking for one because I'm curious by nature and additionally because I simply take the garbage collector f…

> Where can someone (i.e., in my case a software engineer who's working with Kotlin but has used C++ in his past) read more about modern approaches to writing embedded software for such systems? The JPL coding guidelines for C [1] are an amusing, first-hand read about this stuff. Not sure if you would qualify them as "modern approaches". [1] https://en.wikipedia.org/wiki/The_Power_of_10:_Rules_for_Dev...

> A minimum of two runtime assertions per function.

I am guessing the idea is to catch runtime errors in the test phase, and assertions are disabled for the production build.

Re: Does memory leak? (1995)

#165
post #39
post #16

Earlier quoted context omitted.

This is clearly not my subject area. Why would we be spawning processes for HTTP requests? This sounds awful for performance. My best guess is a security guarantee.

Killing a process is much safer than killing a thread, and the OS does cleanup. It's not great for maximizing performance but it's not 100s of milliseconds either, forking doesn't take long; what is slow is scripting languages loading their runtimes, but you can fork after that's loaded. If hardware is cheaper than opportunity cost of adding new features (rather than debugging leaks) it makes sense.

I measured less than half a millisecond to fork, print time, and wait for child to exit.

http://paste.dy.fi/NEs/plain

So forking alone doesn't cap performance too much; one or two cores could handle >1000 requests per second (billions per month).

Re: Does memory leak? (1995)

#167
post #71

Earlier quoted context omitted.

Straight out of college, I was offered a job writing software for missiles. Extremely interesting area, working for my adjunct professor’s team, who I highly admired and whose class was the best of my college career. The pay was on par with all my other offers. I didn’t accept for two reasons. First, I logically agreed that the missiles were supporting our armed services and I believed that our government was general…

> he pulled me aside and sternly instructed “You should never repeat that story” We really need more exposure for the things that people like that want to silence..

He wasn’t silencing anyone. There were no black suits with billy clubs outside.

He was warning the kid that if he went around repeating that aloud he’d burn himself on the interview trail as someone too naive to tow the corporate line and likely to reveal embarrassing workplace details to outsiders.

He was doing the naive youngster a favor, before he could hurt his own career.

The use of the phrase “people like that” is pretty much always pejorative, in a story where a guy who owes the student absolutely nothing took a moment to warn him “don’t touch the stove, you’ll burn yourself”.

So it’s become a story about government contractors instead of a story about “how I fucked up my job search as a new grad.”

Thank you, random kind recruiter guy.

Re: Does memory leak? (1995)

#168
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...

> 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

The example I gave was for the old times when people had much less RAM and the disks had to move physical heads to access different areas. Now with the SSDs you shouldn't be able to experience it that bad (at least when using lower level approaches). How do you start that action? Do you use GUI? Are the files "deleted" to the recycle bin? The fastest way is to do it is "low level" i.e. without moving the files to the recycle bin, and without some GUI that is in any way suboptimal (I have almost never used Windows Explorer so I don't know if it has some additional inefficiencies).

https://superuser.com/questions/19762/mass-deleting-files-in...

Re: Does memory leak? (1995)

#169
post #115

Earlier quoted context omitted.

I had a family friend who worked on missiles and drones and other defense systems. He was really one of my dad’s running buddies, and he was a super nice guy, had 4 kids, went to church, etc. One day, I believe during the Iraq occupation, maybe ~12 or 13 years ago, I asked him very directly how he felt about working on these killing machines and whether it bothered him. He smiled and asked if I’d rather have the war…

Costa Rica hasn’t had a standing military since 1948. They are in one of the most politically unstable parts of the world and do just fine without worry of invasion. The US hasn’t been attacked militarily on its own soil in the modern era. The US military monopoly hasn’t prevented horrific attacks such as 9/11 executed by groups claiming to be motivated by our foreign military campaigns. I think there is a valid ques…

The US was last attacked in living memory; Pearl Harbor survivors still number > 0.

I will leave the WTC attack on the table, as I’m not interested in a nitpicking tangent about what constitutes an attack in asymmetric warfare vs. “terrorism.”

“The modern era” is usefully vague enough to be unfalsifiable.

Re: Does memory leak? (1995)

#170
post #141
post #68

Erlang has a parameter called initial_heap_size. Each new actor-process in Erlang gets its own isolated heap, for which it does its own garbage-collection on its own execution thread. This initial_heap_size parameter determines how large each newly-spawned actor’s heap will be. Why would you tune it? Because, if you set it high enough, then for all your short-lived actors, memory allocation will become a no-op (= bum…

The games and GPU apps I’ve worked on use memory pools for small allocations, where there will be individual pools for all, say, 1-16 byte allocations, 16-64 byte allocations, 64-256 byte allocations, etc. (Sizes just for illustration, not necessarily realistic). The pool sizes always get tuned over time to match the approximate high water mark of the application. I think pools and arenas mean pretty much the same th…

I've seen Jason Gregory talk about per frame arenas in Game Engine Architecture as a fundamental piece of how the Naughty Dog engines tend to work.

Totally agreed that they aren't required for shipping great console games (and they're really hard to use effectively in C++ since you're pretty much guaranteed to have hanging references if you don't have ascetic levels of discipline). This is mainly just meant as a "here's an example of how they can be used and are by at least one shop".

Post reply on HN