All Apps and Add-ons

InputStreamMonitor.updateBody throwing OutOfMemoryError for writing of InputStream in FileOutputStream

New Member

I'm writing file from network (using HttpURLConnection) to my device with code:

                BufferedInputStream bis = new BufferedInputStream(c.getInputStream());
                byte[] buffer = new byte[1024];
                int count = 0;
                long downloadedBytes = 0;
                while ((count = bis.read(buffer)) != -1) {
                    fos.write(buffer, 0, count);
                    downloadedBytes += count;
                }
                fos.close();
                bis.close();

When downloaded file is big (19MB), splunk throws RuntimeException:

java.lang.RuntimeException: An error occured while executing doInBackground()
                      at android.os.AsyncTask$3.done(AsyncTask.java:299)
                      at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
                      at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
                      at java.util.concurrent.FutureTask.run(FutureTask.java:239)
                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
                      at java.lang.Thread.run(Thread.java:841)
                   Caused by: java.lang.OutOfMemoryError
                      at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:94)
                      at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:145)
                      at java.lang.StringBuffer.append(StringBuffer.java:219)
                      at com.splunk.mint.network.io.InputStreamMonitor.updateBody(InputStreamMonitor.java:118)
                      at com.splunk.mint.network.io.InputStreamMonitor.read(InputStreamMonitor.java:78)
                      at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:142)
                      at java.io.BufferedInputStream.read(BufferedInputStream.java:309)
                      at java.io.InputStream.read(InputStream.java:163)

I tried Mint.addURLToBlackList - for domain name (domain.com) and for file (domain.com/file.ext), but doesn't work. I don't want to disable network monitoring. Is there any way, to download large file without this error?

Tags (2)
0 Karma

Splunk Employee
Splunk Employee

We recommend using MINT Gradle Plugin.

0 Karma
State of Splunk Careers

Access the Splunk Careers Report to see real data that shows how Splunk mastery increases your value and job satisfaction.

Find out what your skills are worth!