为了让我的代码看起来更好一些,我为每个创建的页面创建了一个类。但在该页面中,我创建了该页面的另一个实例以再次加载。前几次它运作良好,但随后应用程序在使用图像和布局时开始挣扎。 我没有再次加载图像,主要图像是全局变量,所以不应该有任何巨大的滞后。
我在pastebin上的 C#类代码:https://pastebin.com/n3WVGNTb
我的输出中也有一些消息,我在这里复制了一些:
01-06 16:11:57.253 I/art (28194): Starting a blocking GC Explicit
01-06 16:11:57.267 I/art (28194): Explicit concurrent mark sweep GC freed 1191(30KB) AllocSpace objects, 23(748KB) LOS objects, 40% free, 16MB/27MB, paused 190us total 13.348ms
01-06 16:11:57.268 D/Mono (28194): GC_TAR_BRIDGE bridges 83 objects 477 opaque 11 colors 83 colors-bridged 83 colors-visible 83 xref 0 cache-hit 0 cache-semihit 0 cache-miss 0 setup 0.09ms tarjan 0.20ms scc-setup 0.06ms gather-xref 0.00ms xref-setup 0.00ms cleanup 0.05ms
01-06 16:11:57.268 D/Mono (28194): GC_BRIDGE: Complete, was running for 15.13ms
01-06 16:11:57.268 D/Mono (28194): GC_MAJOR: (LOS overflow) time 19.71ms, stw 20.25ms los size: 6144K in use: 791K
01-06 16:11:57.268 D/Mono (28194): GC_MAJOR_SWEEP: major size: 7040K in use: 5694K
01-06 16:11:57.365 D/Mono (28194): GC_BRIDGE waiting for bridge processing to finish
01-06 16:11:57.367 I/art (28194): Starting a blocking GC Explicit
01-06 16:11:57.367 D/Mono (28194): GC_BRIDGE waiting for bridge processing to finish
01-06 16:11:57.381 I/art (28194): Explicit concurrent mark sweep GC freed 1173(29KB) AllocSpace objects, 18(504KB) LOS objects, 39% free, 16MB/28MB, paused 191us total 13.372ms
01-06 16:11:57.382 D/Mono (28194): GC_TAR_BRIDGE bridges 82 objects 475 opaque 10 colors 82 colors-bridged 82 colors-visible 82 xref 0 cache-hit 0 cache-semihit 0 cache-miss 0 setup 0.08ms tarjan 0.20ms scc-setup 0.06ms gather-xref 0.00ms xref-setup 0.00ms cleanup 0.05ms
01-06 16:11:57.382 D/Mono (28194): GC_BRIDGE: Complete, was running for 15.36ms
01-06 16:11:57.382 D/Mono (28194): GC_MAJOR: (LOS overflow) time 19.03ms, stw 20.61ms los size: 6144K in use: 791K
01-06 16:11:57.382 D/Mono (28194): GC_MAJOR_SWEEP: major size: 6992K in use: 5666K
由于没有人有想法我会跳过这个问题。我可能会尝试拆分构造函数,以便不会双重调用任何代码 有一件事我注意到:它只发生在" Zeichnen"模式。其中有一个SkiaSharp Finger Drawing界面,比平时多2个图标,但应该完全不同。