jerrellmardis / Amphitheatre

Amphitheatre is an Android TV app that connects with network shares, organizes and serves videos to any Android capable media player app.
Apache License 2.0
437 stars 87 forks source link

Too Many Files in Server Crashes with OOM Exception #52

Open Fleker opened 9 years ago

Fleker commented 9 years ago

I have a pretty large hard drive full of media that I'm connecting using SMB. After about 10 minutes of traversing, the app crashed with the attached exception.

It seems like the problem is keeping all the files stored in the variables at the top of the VideoUtils.getFilesFromDir method.

Currently working on a new method of traversing library to be memory safe

List<SmbFile> results 
Set<SmbFile> seen
Deque<SmbFile> queue

 06-08 00:45:24.891  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ Throwing       
OutOfMemoryError "Failed to allocate a 28 byte allocation with 0 free bytes and 3GB until OOM" 
(recursive case)
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ "AsyncTask #4" 
prio=5 tid=26 Runnable
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ | group="main"    
sCount=0 dsCount=0 obj=0x132188e0 self=0xb8b4f478
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ | sysTid=13915 
nice=10 cgrp=apps/bg_non_interactive sched=0/0 handle=0xb8b4f850
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ | state=R schedstat= 
( 0 0 0 ) utm=8300 stm=2760 core=1 HZ=100
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ | stack=0xa132c000-   
0xa132e000 stackSize=1036KB
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ | held mutexes= 
"mutator lock"(shared held)
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ at 
java.lang.String.replace(String.java:1195)
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ at    
jcifs.smb.SmbFile.getUncPath0(SmbFile.java:1198)
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ at jcifs.smb.SmbFile.
<init>(SmbFile.java:617)
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ at jcifs.smb.SmbFile.
<init>(SmbFile.java:603)
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ at jcifs.smb.SmbFile.   
<init>(SmbFile.java:624)
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ at 
jcifs.smb.SmbFile.doFindFirstNext(SmbFile.java:2018)
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ at 
jcifs.smb.SmbFile.doEnum(SmbFile.java:1745)
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ at 
jcifs.smb.SmbFile.listFiles(SmbFile.java:1722)
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ at    
jcifs.smb.SmbFile.listFiles(SmbFile.java:1655)
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ at 
com.jerrellmardis.amphitheatre.util.VideoUtils.getFilesFromDir(VideoUtils.java:311)
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ at    
com.jerrellmardis.amphitheatre.task.DownloadTaskHelper.getFiles(DownloadTaskHelper.java:62)
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ at   
com.jerrellmardis.amphitheatre.task.GetFilesTask.doInBackground(GetFilesTask.java:82)
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ at    
com.jerrellmardis.amphitheatre.task.GetFilesTask.doInBackground(GetFilesTask.java:42)
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ at  
android.os.AsyncTask$2.call(AsyncTask.java:288)
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ at   
java.util.concurrent.FutureTask.run(FutureTask.java:237)
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ at  
android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ at    
java.lang.Thread.run(Thread.java:818)
06-08 00:45:24.893  13780-13915/com.jerrellmardis.amphitheatre.dev E/art﹕ [ 06-08 00:45:25.108 
13780:13799 I/art      ]
Alloc partial concurrent mark sweep GC freed 2229092(163MB) AllocSpace objects, 0(0B) LOS  
objects, 36% free, 28MB/44MB, paused 749us total 217.836ms
06-08 00:45:25.110  13780-13806/com.jerrellmardis.amphitheatre.dev I/art﹕ 
WaitForGcToComplete blocked for 219.665ms for cause Background
06-08 00:45:25.111  13780-13915/com.jerrellmardis.amphitheatre.dev I/art﹕ 
WaitForGcToComplete blocked for 214.654ms for cause Alloc
06-08 00:45:25.138  13780-13915/com.jerrellmardis.amphitheatre.dev E/AndroidRuntime﹕ FATAL 
EXCEPTION: AsyncTask #4
Process: com.jerrellmardis.amphitheatre.dev, PID: 13780
java.lang.RuntimeException: An error occured while executing doInBackground()
        at android.os.AsyncTask$3.done(AsyncTask.java:300)
        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
        at java.util.concurrent.FutureTask.run(FutureTask.java:242)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
        at java.lang.Thread.run(Thread.java:818)
 Caused by: java.lang.OutOfMemoryError: OutOfMemoryError thrown while trying to throw    
OutOfMemoryError; no stack available
06-08 00:45:25.142     476-1776/? W/ActivityManager﹕ Force finishing activity  
com.jerrellmardis.amphitheatre.dev/com.jerrellmardis.amphitheatre.activity.BrowseActivity
06-08 00:45:25.152  13780-13915/com.jerrellmardis.amphitheatre.dev I/Process﹕ Sending signal. 
PID: 13780 SIG: 9
06-08 00:45:25.245     476-1776/? I/WindowState﹕ WIN DEATH: Window{a3b71c9 u0 
com.jerrellmardis.amphitheatre.dev/com.jerrellmardis.amphitheatre.activity.BrowseActivity}
06-08 00:45:25.354      476-492/? I/ActivityManager﹕ Process com.jerrellmardis.amphitheatre.dev 
(pid 13780) has died