Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
I have a library which performs various calculations on byte array data, using Parallel.For for the outer loop. The data is serial and represents a matrix of ~300x300x4 bytes in its iOS / iPhone / iPad incarnation, but has been tested on much larger matrixes in Windows, where the library originates. The problem manifests itself in the emulator and in hardware, debug and release. Some of the classes calculate inline and have no performance issues. Those which use lightweight support classes perform much, much more slowly when parallized than when made to operate on a single thread. These typically use one or more support objects per byte group. Static methods of these support classes do not have performance issues. This performance issue also manifests itself when using Linq to determine things like highest, lowest, median and average values of sampled data. When some of these library classes were changed to calculate results manually, inline, they became fully performant. The support classes are self-contained, safe and do not use unmanaged resources – they are just intermediate difficulty math.
Below is pretty much how every loop is structured…
Parallel.For(0, iBound, i =>
for (int j = 0; j < jBound; j++)
//Do something to the byte data
Really not very complex, the only additional complication is that is runs on a background thread.
Problem is iOS garbage collection. Furious reworking to make whatever I couldn't inline be instantiated once per thread gets around this.