> Serious performance problems when running on Mac OSX

I have a question regarding C#, Mono and OSX. I have created a Program in C# using Windows Forms and am trying to make it usable on a Mac.

Problem is, that the performance is extremely poor on OSX and I just can´t find a way to speed it up. The program itself is quite simple actually: A Client Server System using just two DataGridViews, a few ComboBoxes and Buttons, a TabControl, a few SplitContainers - and thats it! Works fine on Windows and has no speed problems whatsoever.

When I open the program on a Mac (MacBook Air, OSX Version 10.8.3) it takes ages to load the GUI. Building it up takes about 0.5sec on WIndows and nearly a Minute on a Mac(!). All the controls are built up very slow and most of the time when interacting with the program by clicking on something it takes another minimum of 10secs to respond.

I´ve learned that Mono natively builds up the GUI using Windows.System.Drawing. Is that a possible reason for the extremely slow response of the program? What can I do to speed up the programm? There must be some way, as Mono would be fairly useless if it´s not even usable for such a simple program...

I have spent hours trying to google an answer to my issue and just can´t find anything usefull: AheadOfTime-Compiling, LLVM - nothing improves the performance.

Thanks a lot for your answers in advance!

Chris

UPDATE: I´ve decreased the perfomance issue a bit now. Mono seems to have problems with the CellFormating of Gridviews. I changed the code in the applicable parts and it´s running faster now.

Nevertheless it still takes ages to build up the GUI. You can literally watch it build the GUI. Any suggestions on that?


The loading time is likely the JIT compiling your code for the first time (takes my assemblies about 30-60 seconds to boot up the first time too); running your program a second time should load much faster. On Windows, Visual Studio will AOT your assembly as part of the compilation, so the first boot up is fast. The slow control performance I believe is due to the font-rendering (it's not even good looking rendering either). On top of that, keyboard handling is wrongly implemented and since Mountain Lion, you'll also need users to download XQuartz.

Mono is useful, but its WinForms implementation isn't. If OS X support is important to you, your options are as follows:

  • Use a different toolkit (GTK#, WX.Net, etc).
  • Build a Cocoa Library DLL using XCode and PInvoke it from C#.
  • The safest bet is the latter, but if your needs are simple, it might be easier to just use a different toolkit.


    You will have to debug on a Mac or Linux to find what exactly is running so poorly. Mono has some implementations that are surprisingly slow. While you see the symptom of slow UI, the cause may be something else entirely.

    For example, in a similar situation, I found that XmlDocument was very slow because I was researching why the UI was so sluggish. If you are using XmlDocument to store the data from the server, it could cause your UI to be slow and barely responsive.

    链接地址: http://www.djcxy.com/p/70648.html

    上一篇: jvectormap:在标记之间画线?

    下一篇: >在Mac OSX上运行时出现严重的性能问题