0

I get an OutOfMemoryError in my app:

FATAL EXCEPTION: Thread-11746
Process: kr.co.iosystem.blackeyeonandroid, PID: 1618
java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Try again
at java.lang.Thread.nativeCreate(Native Method)
at java.lang.Thread.start(Thread.java:1063)
at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:921)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1337)
at com.android.okhttp.ConnectionPool.addConnection(ConnectionPool.java:208)
at com.android.okhttp.ConnectionPool.recycle(ConnectionPool.java:198)
at com.android.okhttp.OkHttpClient$1.recycle(OkHttpClient.java:111)
at com.android.okhttp.internal.http.HttpConnection$AbstractSource.endOfInput(HttpConnection.java:377)
at com.android.okhttp.internal.http.HttpConnection$FixedLengthSource.read(HttpConnection.java:426)
at com.android.okhttp.okio.RealBufferedSource$1.read(RealBufferedSource.java:349)
at java.io.InputStreamReader.read(InputStreamReader.java:233)
at java.io.BufferedReader.fillBuf(BufferedReader.java:145)
at java.io.BufferedReader.readLine(BufferedReader.java:397)
at com.github.nkzawa.engineio.client.transports.PollingXHR$Request.onLoad(PollingXHR.java:292)
at com.github.nkzawa.engineio.client.transports.PollingXHR$Request.access$600(PollingXHR.java:135)
at com.github.nkzawa.engineio.client.transports.PollingXHR$Request$1.run(PollingXHR.java:214)
at java.lang.Thread.run(Thread.java:818)

I check my log but I don't know where the outofmemory occurs in my source.

How to fix the outofmemory problem?

Dima Kozhevin
  • 3,602
  • 9
  • 39
  • 52
hyunwooks
  • 141
  • 3
  • 14
  • Try moving all the heavy images from `drawable` folder to `drawable-nodpi` folder. Check this [link](https://medium.com/@oronno/android-drawable-outofmemoryerror-ebe2995760b6) – Shruti Sep 25 '17 at 06:41
  • https://stackoverflow.com/a/46401786/3395198 – IntelliJ Amiya Sep 25 '17 at 10:54

3 Answers3

0

You have to find where you are doing memory intensive tasks. You have to avoid memory leaks also. You can use a library to track memory leaks. https://github.com/square/leakcanary

Ashish Tiwari
  • 2,168
  • 4
  • 30
  • 54
-1

In your manifest application section add following below

       android:largeHeap="true"> 

This is the temporary solution you have to find out the real causes and solve

vishal jangid
  • 2,967
  • 16
  • 22
-1

Use android:largeHeap="true" to solve this

Check that the image size is smaller than the available memory before attempting to load it. So the most efficient way to handle OutOfMemoryException is to architecture your application in such a way that it never attempts to load lots of data into memory in order to avoid the exception.

Geeta Gupta
  • 1,622
  • 11
  • 17
  • I don't think that `allowBackup` will be helpful here, neither `largeHeap`. Although I agree with the fact that you need to have a good architecture that doesn't use too many resources at the same time. Also, an app leaks free is what you should try to achieve since from my experience these caused most of the crashes. – Iulian Popescu Sep 25 '17 at 06:53
  • @Geeta Gupta I know `android:allowBackup="true"` is set auto backup option. why you set `allowBackup` manifest my source? – hyunwooks Sep 25 '17 at 06:56
  • `android:allowBackup="true"` wrong point . – IntelliJ Amiya Sep 25 '17 at 07:00