4

I tried to make a .map file to use it in my android application. My point is to show map on screen with help of mapsforge library. Library requires a .map file. The problem is generating it with osmosis mapfilewriter plugin. When I use command

./osmosis --rx file=/home/user/poland.osm --mw file=result.map bbox=51.09,16.9,51.14,17

I get

SEVERE: Thread for task 1-rx failed
java.lang.OutOfMemoryError: Java heap space

I tried using another order of arguments but it also doesn't work. I also tried using -Xmx1200m option to increase javas heap memory but usage of memory was this same and didn't help.

I would be grateful for help.

2 Answers 2

3

Use the parameter type=hd.

The type parameter has two options ram and hd. Although I don't see that the documentation doesn't explicitly state what hd means, I would guess it means "hard disk", meaning it would offload data to disk, rather than keeping it all in memory.

The resulting command would be then:

./osmosis --rx file=/home/user/poland.osm --mw file=result.map bbox=51.09,16.9,51.14,17 type=hd
1
  • 1
    Indeed. This will solve most memory issues for larger maps - at the cost of slowing down the processing; in my experience, the disk-based temporary storage is somewhat larger than a memory-based one, so be sure to have enough free space. Apr 23, 2014 at 8:58
2

If you have enough memory, you need to tell Java about it (it will only use a limited amount otherwise); but this is not an argument passed directly to osmosis.

On Windows, you can follow this advice given by Emilie Laffray on the OSM-dev list:

In osmosis.bat is the following line... REM # JAVACMD_OPTIONS - The options to append to the java command, typically used to modify jvm settings such as max memory.

so, either modify osmosis.bat or, create a new file called osmosis.bat in the all users profile directory or your profile directory, to include a 'set JAVACMD_OPTIONS = -Xmx1024M' line (to set maximum memory usage to 1GB, if you have enough RAM)...

On Linux (and I'd assume Mac OS X also), you can create the file ~/.osmosis containing the line

JAVACMD_OPTIONS=-Xmx1024M 

which will be loaded by osmosis on startup. Note that both examples above use the value 1024M, i.e. you're giving Java access to 1024 MB of RAM - you could use a different value depending on your system.

1
  • Do you know if this could apply to other Java software by default? E.g.: let's say instead of osmosis (Java based program) we have xyz (which is Java based too). Creating a ~/.xyz file with the content described above, would it automatically take this setting?
    – xarlymg89
    Jun 2, 2021 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.