I would like to simulate a stack memory leak. The stack means the value list in as dumpsys meminfo com.sample.demo
(428Kb in below sample):
App Summary
Pss(KB) Rss(KB)
------ ------
Java Heap: 8016 30776
Native Heap: 6428 10600
Code: 21784 86164
Stack: 428 440
Graphics: 5268 5268
Private Other: 2972
System: 4370
Unknown: 7384
TOTAL PSS: 49266 TOTAL RSS: 140632 TOTAL SWAP (KB): 3432
I have try to use new ArrayList<>();
but it allocate memory in Java
category.
Create an infinite recursive function and trigger it:
private void call() {
call();
}
To increase the frame size, allocate some primitives in the function. Also, the app most likely will be killed with a StackOverflow exception - so add a counter and check it before calling the function.