Last active
September 4, 2015 15:34
-
-
Save lukhnos/65840aa045d79c98bf1f to your computer and use it in GitHub Desktop.
Demonstrates that Throwable leaks memory in j2objc, see https://github.com/google/j2objc/issues/601
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.j2objc.annotations.AutoreleasePool; | |
public class ThrowableLeaks { | |
public static void main(String args[]) { | |
for (int i = 0; ; i++) { | |
foo(i); | |
bar(i); | |
try { | |
Thread.sleep(1000); | |
} catch (Exception e) { | |
} | |
} | |
} | |
@AutoreleasePool | |
public static void foo(int i) { | |
System.out.println(i); | |
try { | |
if ((i % 20) == 0) { | |
throw new AssertionError("lost"); | |
} | |
} catch (Throwable e) { | |
} | |
} | |
@AutoreleasePool | |
public static void bar(int i) { | |
if ((i % 30) == 0) { | |
new Throwable("something"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment