Android performance

I’m using Graphhopper in my android app (for personal use).
You did a wonderful job.
I’m stuck with version 0.6 for various reasons, but it’s ok for my needs.
I have only one problem: slow routing time for 500+ Km routes without CH due to android memory limitations.
I already searched forums and get some improvements using A* BI algo and increasing epsilon, but it’s still very slow in some cases, so I tried to go deeper.
After adding “largeHeap” in manifest on my P8 Lite (2015) with 2GB ram my app has max heap size = 512 MB.
forDesktop() improves performance, but causes OutOfMemoryError when allocated memory exceeds 512 MB.
With forMobile() allocated memory starts at 20 MB, grows really slow, it reaches about 50% of 512 MB and routing is still slow.
So my question is: is there a way to increase allocated memory size with MMAP / forMobile()?

Thanks in advance

As you found, the largeHeap is one way to push more memory in the application.

If going with regular Java and not native calls, usually cannot access more memory than the available VM heap, like happens also on desktop.

Actually GraphHopper issue #1 is about memory restricted environments. :slight_smile:

Yes, but as you surely know VM heap has maximum memory and allocated memory.
With largeHeap my app on my phone has 512 MB of maximum memory.
I’ll try to explain better.

If I use forDesktop() allocated memory grows and reaches 487.360 MB in less than 1 minute, even without do anything.
I tried several times, always the same allocated memory and 16 MB of free memory.
500 Km routing is calculated in about 2-3 seconds and allocated memory rises to 505-508 MB.
Longer routing cause OOM because allocated memory exceeds 512 MB.

If I use forMobile() after loading GH allocated memory is about 20 MB and stays there.
500 Km route is calculated in 7-8 seconds, allocated memory grows slowly and reaches about 50 MB.
With 585 Km route after about 2 minutes allocated memory is about 100 MB and still calculating.

So my question is if GH with forMobile() can allocate more memory and perform faster.

Can see also my similar observations in #499 for large (country) sized routing (depending the size).

Note that as seen in code, forDesktop uses in-memory graph, while forMobile memory mapped.

I noticed, I’ve already searched code and forums before bothering you :wink:
I analyzed and debugged the code trying to understand how memory mapped works to find a way to make it allocate more available memory, but I lost myself.
I’m not so deep into java and android, so I hoped you can help me.