Mapsui: memory exception

Created on 29 Oct 2019  路  6Comments  路  Source: Mapsui/Mapsui

I'm working on app in winforms, using Mapsui, which is hosted by ElementHost on form.
Ususally everything is ok, but when system is routing large route, maps throwing Memory Exception from SkiSharp.
I've started checking this issue, I've cloned repo /every version/ and i put my line string to sample as const WKTGr5 in
Mapsui.Samples.Common.Maps.LineStringSample, to check if ElementHost is not responsible for this issue, but no, maps are stiil failing, but only in Release mode, when is debug mode enebled everything is fine. I'm guessing that probably optimization in Mapsui is responsible for that situation.

I attached file with my LineString /it hass about 3000km/, you can put it to sample and check issue.
To reproduce the issue, scroll map to last point in Alps, zoom in to minimum, and zoom out, try to move map few times. Exception is not deterministic.

Exception is throwing in LineStringRenderer.cs line 59.
Currently I'm checking Commit d29a339e96087f87de76d3ec30453241cf6b4c23

Btw very good job!!!
path.txt

bug 馃悰

All 6 comments

Thanks to your specific instruction I could reproduce this bug quickly.

image

An update.

Looking at the code and googling a bit did not give to much pointers.

  • Keeping a pointer to the canvas can be an issue, but that is not happening.
  • Disposing things that are still in used could be a cause. We do dispose unused features but maybe there is something going wrong there. So far I don't see what.
  • I thought drawing locations far outside the can extent might be a problem. But we are clipping linestring. (not sure how we deal with extreme tiles).
  • An older version of skia or skiasharp might be a problem but I did immediately found bug reports about this.

Reproducing it can take a long time sometimes which makes it hard to track. I tried to reproduce it with the tile layer off and could not, but you can never be sure if it is just chance.

Thank you for interest this issue.
I checked both versions 1.60 and 1.68, and on both is the same situation, when I find a bit time i'll try to identity this issue, but I cannot promise :(
Right now I'm using mapsui without optimisation, but is not a good solution.

ah, good to know. There is now also a pre-release of skiasharp, btw. 1.68.1-rc.153.

Yerstarday I did some research, and in my opinion responsible is GC which to fast relising memory for path,

when I put one line of code after
canvas.DrawPath(path, paint);
eg.
var a = path.IsEmpty;

exception is not throwing.

My proposition is to add after:
canvas.DrawPath(path, paint);
line:
path.Dispose();

which tell GC to consciously handle releasing memory for path.
On my machine this solution works fine, could you confirm taht on yours machine exception is not throwing?

Ah, there is no Dispose at all right now. Not sure how this causes the error but there just should be a dispose. I have added it now with a using statement and can not reproduce the problem anymore. So I consider this fixed. Thanks a lot for the analysis!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pauldendulk picture pauldendulk  路  7Comments

lukaszpitulski picture lukaszpitulski  路  3Comments

lukaszpitulski picture lukaszpitulski  路  3Comments

lukaszpitulski picture lukaszpitulski  路  8Comments

charlenni picture charlenni  路  3Comments