Graphhopper in Android app - gives OOM

While upgrading my Andoid app I used a newer gradle dependency for Graphhopper:

implementation group: 'com.graphhopper', name: 'graphhopper-core', version: '7.0'

When starting the Graphhopper part of my app, I get this error:

java.lang.OutOfMemoryError: Failed to allocate a 392 byte allocation with 185320 free bytes and 180KB until OOM, target footprint 268435456, growth limit 268435456; giving up on allocation because <1% of heap free after GC. at java.util.Arrays.copyOf(Arrays.java:3766) … at com.graphhopper.GraphHopper.load(GraphHopper.java:1048)

I had to change the calls to Graphhopper, since there was no Graphhopper for Mobile anymore.

GraphHopper hopper = new GraphHopper();
hopper.setProfiles(new Profile("foot").setVehicle("foot").setWeighting("fastest"));
hopper.setGraphHopperLocation(routingDataFolder);
hopper.importOrLoad();

How can I get this running without memory issues?

Hiya, i tend to preprocess my graph on a device with a lot of memory, then copy it over.

Have you also tried allocating more memory in java environment?

Thank you.

Via Graphhopper on my desktop I first generated the files: edgekv_keys, edgekv_vals, edges, geometry, location_index, nodes, nodes_ch_foot, out, properties, shortcuts_foot.
Then I copied them to my mobile.
Then I used them with the above statement.

Q: Is this how you do that?
Q: Can I use the same Graphhopper-core both on my desktop and on my mobile?
Q: Can I restrict the memory usage for Graphhopper on my mobile?

Sorry for late response.
Yes, that is how I essentially do it.
I do not develop for mobile, I would suggest that the underlying graph is identical.

Graphhopper will require as much system memory to complete successfully. I’m unaware of limiting the amount available, instead it is the other way round, ensure it has enough or it will fail.
I can remember a post suggesting that if you are generating a graph with different vehicle profiles, you can stagger these to produce one at a time for each vehicle. Eg. Build with car, clear memory, run with walk etc.