Hacker News new | past | comments | ask | show | jobs | submit login

How does java prevent memory leaks which rust couldn't ? Do you have examples for that? I was not aware that Java does it and am very interested in that.



One of the advantages of a tracing garbage collector is that it can recognize cycles. This means that if you have a few objects which point to each other, but the overall object graph is dead, a tracing GC should be able to collect these objects.

If you use reference counting in Rust, it will not be able to detect cycles. That said, it's not super easy to get a cycle accidentally.


Thank you. In hindsight, this was pretty obvious and I knew it already but I somehow didn't connect the pieces.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: