All Apps and Add-ons

InputStreamMonitor.updateBody throwing OutOfMemoryError for writing of InputStream in FileOutputStream

malpasdd
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

croyal_splunk
Splunk Employee
Splunk Employee

We recommend using MINT Gradle Plugin.

0 Karma
Get Updates on the Splunk Community!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...