Performance LowProfileImageLoader退出内存异常Windows Phone
我使用LowProfileImageLoader异步加载图像,而不使用块UI 您可以从以下链接获取: 若列表的数据源有许多不同的链接,那个么一切都正常 但是现在,我想用所有相同URL的数据源进行测试,所以在TwitterService.cs文件中,我编辑了以下内容:Performance LowProfileImageLoader退出内存异常Windows Phone,performance,windows-phone-7,asynchronous,out-of-memory,loadimage,Performance,Windows Phone 7,Asynchronous,Out Of Memory,Loadimage,我使用LowProfileImageLoader异步加载图像,而不使用块UI 您可以从以下链接获取: 若列表的数据源有许多不同的链接,那个么一切都正常 但是现在,我想用所有相同URL的数据源进行测试,所以在TwitterService.cs文件中,我编辑了以下内容: private static void HandleGetFollowersResponse(IAsyncResult result) { var state = (GetFollowersS
private static void HandleGetFollowersResponse(IAsyncResult result)
{
var state = (GetFollowersState)result.AsyncState;
//#if DEBUG
try
{
//#endif
//using (var response = state.Request.EndGetResponse(result))
//{
// using (var stream = response.GetResponseStream())
// {
// var document = XDocument.Load(stream);
// Deployment.Current.Dispatcher.BeginInvoke(() =>
// {
// foreach (var user in document.Element("users_list").Element("users").Elements("user"))
// {
// state.Collection.Add(new TwitterUser(user.Element("screen_name").Value, new Uri(user.Element("profile_image_url").Value)));
// }
// });
// var nextCursor = document.Element("users_list").Element("next_cursor").Value;
// if ("0" == nextCursor)
// {
// // Load completed
// if (null != state.OnFollowersLoaded)
// {
// Deployment.Current.Dispatcher.BeginInvoke(() => state.OnFollowersLoaded());
// }
// }
// else
// {
// // Load the next set
// MakeGetFollowersRequest(state.ScreenName, nextCursor, state.Collection, state.OnFollowersLoaded);
// }
// }
//}
throw new WebException();
//#if DEBUG
}
catch (WebException)
{
//No network access; create some fake users for debugging purposes
for (var i = 0; i < 200; i++)
{
state.Collection.Add(new TwitterUser("Fake User " + i, new Uri("http://4.bp.blogspot.com/-O-6vxSiyvbk/UClib6CiR0I/AAAAAAAAQaI/5Fr1dI-kQBI/s1600/Flowers+beauty+desktop+wallpapers.+(1).jpg")));
}
if (null != state.OnFollowersLoaded)
{
Deployment.Current.Dispatcher.BeginInvoke(() => state.OnFollowersLoaded());
}
}
//#endif
}
文本日志显示,加载图像后,图像内存增加了~3mb,尽管图像大小(来自URL)仅为120kb。
为什么OutofMemoryException抛出?
为什么垃圾收集不打电话,我的记忆稳步增长
任何帮助都是非常合适的。
先谢谢你
虽然图像大小(来自URL)仅为120kb,但图像内存增加了~3mb
当图像显示时,必须从JPEG解码,因此占用更多内存是正常的。尝试使用Paint将图像转换为BMP以查看它
为什么OutofMemoryException抛出
您可能会超过90 MB的限制
为什么垃圾收集不打电话,我的记忆稳步增长
查看这篇诺基亚文章:谢谢。但我还有另一个问题:若列表的数据源有不同的链接,为什么一切都正常?我的意思是,数据源有不同的链接,因此内存也会随着内存大小的减小而增加(通常<1mb,并且我确定该URL的图像大小~在使用相同URL的情况下,URL的图像大小);
private static void WorkerThreadProc(object unused)
{
// Process pending completions
if (0 < pendingCompletions.Count)
{
// Get the Dispatcher and process everything that needs to happen on the UI thread in one batch
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
while (0 < pendingCompletions.Count)
{
Logger.printUsedMemory();
}
}
}
}
Used memory: 21966848
Used memory: 25051136
Used memory: 28442624
Used memory: 32673792
Used memory: 35512320
Used memory: 39079936
Used memory: 43364352
Used memory: 46571520
Used memory: 49815552
Used memory: 53497856
Used memory: 52514816
Used memory: 55902208
Used memory: 60452864
Used memory: 62001152
Used memory: 65503232 ~ 65.5mb
Used memory: 69005312 ~ 69mb