News for hackers. Stuff that matters.
Re:Maps and Memory Leaks in Go by TheDong on Tuesday November 08, 2022 @04:33AM (#33517488)
> a memory leak in a memory-safe language would really be a big deal...

It is not.

Let me show you a memory leak in the memory safe language, rust:

    let vec: Vec<u8> = Vec::with_capacity(1024);
    std::mem::forget(vec);
Let me show you a memory leak in the memory safe language, go:

    _ = time.Tick(1 * time.Second)
See the docs for time.Tick in the stdlib, which documents that calling it is a memory leak: https://pkg.go.dev/[email protected]#Tick

You can also, if you want to leak memory in go, set the environment variable GOGC=off, and there you go, instant memory leak.

Practically any language, memory safe or otherwise, will let you create a memory leak.

There are no comments on this comment yet.