News for hackers. Stuff that matters.
Re:Rust is a hard way to make a web API by fctorial on Friday January 15, 2021 @10:32PM (#25799780)
> You can still have memory leaks in GC-d languages by reference cycles.

    public class T {
      Object ref;

      @Override
      protected void finalize() {
        System.out.println("finalize");
      }

      static void leak() {
        T a = new T(), b = new T();
        a.ref = b;
        b.ref = a;
      }

      public static void main(String[] as) throws Throwable {
        leak();
        System.gc();
        Thread.sleep(10000);
      }
    }
Re:Rust is a hard way to make a web API by monocasa on Friday January 15, 2021 @11:50PM (#25800141)
A full GC will count the a and b objects as garbage once leak returns.
Re:Rust is a hard way to make a web API by fctorial on Saturday January 16, 2021 @01:30AM (#25800535)
Yes it will. The snippet counters the statement.