Reputation: 2216
I think I expect this behavior but I'm not sure, since I see pc versions of the browsers to unload and load pictures following a memory limit. The thing is my workmate has done a very alpha version of a webapp that shows lots of pictures, and as you scroll down it loads even more.
There is a point where when you scroll down, it doesn't load anymore and its either closed by android or force closed by it (crashing). Can I change something on the webview to make it behave as the pc version of chrome or do I have to tell my workmate to avoid loading all the pictures at once? (may be changing the src attribute for img tags to '' would make the webview to release them?).
I've used MAT to see if the memory problem was on java side, but there the heap was only 6mb, the process though was 130mb in one device and 300 in another just before being closed.
Any pointers to how could I solve the problem? Thanks!
Upvotes: 0
Views: 802
Reputation: 3430
You can do following things:
1.get the available memory at runtime by calling getMemoryClass() and based on memory either scale the images or limit the no of images.
2.Use largeHeap in manifest so that your app get more memory allocated at run time.The docs says
Whether your application's processes should be created with a large Dalvik heap. This applies to all processes created for the application. It only applies to the first application loaded into a process; if you're using a shared user ID to allow multiple applications to use a process, they all must use this option consistently or they will have unpredictable results.
Most apps should not need this and should instead focus on reducing their overall memory usage for improved performance. Enabling this also does not guarantee a fixed increase in available memory, because some devices are constrained by their total available memory.
To query the available memory size at runtime, use the methods getMemoryClass() or getLargeMemoryClass().
3.add around the
4.dynamically add remove images through javascript
Upvotes: 1