我的應用程序出現問題,我不知道它是否正常。 我在我的應用程序中需要顯示大量文本(2000-4000字符)的文本塊。無論如何,有2048像素的限制,我認爲我的文字被裁剪,這是沒有問題的,我使用這個:http://blogs.msdn.com/b/priozersk/archive/2010/09/08/creating-scrollable-textblock-for-wp7.aspx。wp7 - 帶有大量文本的TextBlock - 巨大的內存使用 - 如何避免它?
問題是,文本越長,它消耗的內存就越多。如果沒有上面鏈接的長文本破解,textblock會消耗大約10mb的內存! 如果我從上面的鏈接中使用ScrollableTextBlock,內存的數量會更大,可以達到30-40 mb ..沒有限制。 因此,內存使用似乎與繪製區域有關...
有沒有辦法減少長文本的內存使用量? BitmapCach與這個問題有什麼關係,我可以禁用它嗎?您可以通過添加一個文本塊很長的文本塊來輕鬆地重現此問題,並且可以使用此代碼檢查內存使用情況,您將看到只有1個帶有長文本的文本塊,峯值內存增加了10mb或更多:
long deviceTotalMemory = (long)DeviceExtendedProperties.GetValue("DeviceTotalMemory");
long applicationCurrentMemoryUsage = (long)DeviceExtendedProperties.GetValue("ApplicationCurrentMemoryUsage");
long applicationPeakMemoryUsage = (long)DeviceExtendedProperties.GetValue("ApplicationPeakMemoryUsage");
Debug.WriteLine("### deviceTotalMemory : " + deviceTotalMemory);
Debug.WriteLine("### applicationCurrentMemoryUsage : " + applicationCurrentMemoryUsage);
Debug.WriteLine("### applicationPeakMemoryUsage : " + applicationPeakMemoryUsage);
你有沒有想過分頁文本,而不是試圖一次性顯示它? – 2011-01-31 16:25:37
是的,但我想知道這是否正常,以及是否有解決辦法(除了分頁)。這是一個巨大的內存。 – johnX99 2011-01-31 16:51:46