Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch Out of memory error and display a nice error message #114

Open
Strubbl opened this issue Feb 11, 2022 · 2 comments
Open

Catch Out of memory error and display a nice error message #114

Strubbl opened this issue Feb 11, 2022 · 2 comments
Assignees
Labels
bug Something that went wrong

Comments

@Strubbl
Copy link
Contributor

Strubbl commented Feb 11, 2022

I would like to propose a small improvement for the situation, where the machine on which the renderer runs does not have enough free RAM. Maybe it is better to fail gracefully and catch the OOM and display a nice message instead of the python stack trace?

map-machine render --cache /maps/cache -z 19 -o /maps/cotopaxi.svg -b" -78.551165,-0.745289,-78.276507,-0.513904"
INFO Constructing ways...
INFO Constructing nodes...
INFO Drawing ways...
Traceback (most recent call last):
  File "/usr/local/bin/map-machine", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/map_machine/main.py", line 32, in main
    mapper.render_map(arguments)
  File "/usr/local/lib/python3.9/site-packages/map_machine/mapper.py", line 316, in render_map
    map_.draw(constructor)
  File "/usr/local/lib/python3.9/site-packages/map_machine/mapper.py", line 92, in draw
    occupied = Occupied(
  File "/usr/local/lib/python3.9/site-packages/map_machine/pictogram/point.py", line 27, in init
    self.matrix = np.full((int(width), int(height)), False, dtype=bool)
  File "/usr/local/lib/python3.9/site-packages/numpy/core/numeric.py", line 343, in full
    a = empty(shape, dtype, order)
numpy.core._exceptions._ArrayMemoryError: Unable to allocate 8.23 GiB for an array with shape (102399, 86271) and data type bool
@enzet
Copy link
Owner

enzet commented Feb 12, 2022

Oh. Thank you! I've never tested it for such a big pictures.

Yes, I think firstly I should add some error handling, but the overlap computing algorithm itself is quite primitive. I have to make it more optimal in the future.

@enzet enzet self-assigned this Feb 15, 2022
@enzet enzet added the bug Something that went wrong label Feb 15, 2022
enzet added a commit that referenced this issue Feb 17, 2022
If the resulting canvas is too big, overlap algorithm may fail to
create matrix for occupied space.
@enzet
Copy link
Owner

enzet commented Feb 17, 2022

I've added simple wrapping for this part of code, but on my computer this leads to SIGKILL and not an numpy exception.

I'll think on how to rewrite the overlap algorithm to support such cases.

@enzet enzet moved this to In Progress in Project support May 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that went wrong
Projects
Status: In Progress
Development

No branches or pull requests

2 participants