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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...