Create a memory leak given an interface to conform to
This question already has an answer here:
A simple implementation would have a static
list and when doSomething
is called, just keep adding the input String
to the list. The reason why is because you're storing a strong reference (via the static member) to the strings so the strings cannot be garbage collected.
上一篇: 你如何使JVM崩溃?
下一篇: 创建一个内存泄漏给定一个接口符合