Javasenior level

2 questions pitched at this level, most-asked first.

  • How do you get a memory leak in a garbage-collected language?

    The collector frees what is unreachable, not what is finished with — so a leak in Java is unwanted reachability, not a missing free(). Four structures cause almost all of them: a static collection, a registered listener nobody unregisters, a ThreadLocal on a pooled thread, and a ClassLoader held by one stray reference. None of them throws anything until the heap is gone.

    Asked constantlysenior3–15 yrs12 min readJvm
  • What replaced PermGen, and why?

    Java 8 removed PermGen and moved class metadata to Metaspace, in native memory outside the heap. The failure did not go away — it moved. PermGen had a size you set yourself and failed predictably; Metaspace is unbounded by default, so the same leak now grows until the kernel kills the process, with no Java-side error and no heap dump.

    Asked oftensenior3–15 yrs10 min readJvm

Other levels