2 ms·
Almost the same method for e.g. Lua: debug.getregistry()[{}] = big_value debug = nil These aren't really "true" leaks, because from GC point of view the r
by wruza 10y ago
Almost the same method for e.g. Lua:
debug.getregistry()[{}] = big_value
debug = nil
These aren't really "true" leaks, because from GC point of view the referencing object in both cases (ClassLoader, Registry, etc.) is just a hidden gc-root that cannot be reset from regular code. It is the same way you cannot un-leak this C++ pseudocode:
main()
{
p = malloc(1_000_000 * sizeof(int));
App app;
return app.run();
}
... because active stack frame is also a gc-root. From practical point of view though, this definitely leaks, since leaked data cannot be [re]used anywhere.
- wyldfire 10y agoI don't see how this example relates. Your C++ example is a real puzzler. Even if `p` were in use during run(), it could still be (and should still be!) free()d before returning from main(). It's a bit tricky but there's potentially LOTS of code that will execute after "`return app.run()`" but before the process exits.