• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

ExecutorService Doubles Memory in API<26 Android

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My app downloads data from a PHP Server using threads from an ExecutorService with ThreadPool size 4. In API 27, the app runs perfectly without causing any OOM exception from the Heap memory. But all the previous API <26 throws OOM.

Below is a simple code example that executes 134 requests and then adds the response to the pool. In API 27 the maximum Heap size, reaches 68 mb. But when i run it with API 19,21,25 e.t.c the maximum Heap Size reaches 123 mb.

When i remove the Log.d("Process response", (response)+""); in API 27 the Heap Size goes down to 10mb. But with API 19, the Heap Size goes to 60mb.

I cant understand why it doubles the size. It looks like in API 19 and above increases memory when adding tasks in the pool and also when holding the reference in the response variable.

Any suggestions?

**Note**
The thread sleep is for the example only to see the maximum Heap size


Thanks

 
Saloon Keeper
Posts: 14795
333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From what I can read online, API level 27 (Android Go) focuses on reducing system requirements for the Android OS. The decrease in memory footprint is a deliberate design goal of that release.
 
Tony Starkisi
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But the same happens in API 26. Below API 26, memory is doubled. Did you read something about API 26 also?
 
Stephan van Hulst
Saloon Keeper
Posts: 14795
333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure, but level 26 is a major release (Android Oreo) so I wouldn't be surprised if they already made big changes.
 
Tony Starkisi
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So there is no workaround or fix?
 
Stephan van Hulst
Saloon Keeper
Posts: 14795
333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe not keep 134 responses in memory.
 
I have a knack for fixing things like this ... um ... sorry ... here is a consilitory tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic