问题描述
我的库中有超过600000个文件,当我尝试获取splistitemcollection时出现服务器内存不足异常.
my library has over 600000 files and i got Server Out Of Memory exception when i trying to get splistitemcollection.
错误消息:
服务器内存不足.
服务器上没有内存可以运行您的程序.遇到此问题,请与您的管理员联系.< nativehr> 0x8007000e</nativehr>< nativestack></nativestack>
Server Out Of Memory.
There is no memory on the server to run your program. Please contact your administrator with this problem.<nativehr>0x8007000e</nativehr><nativestack></nativestack>
获取splistitemcollection有什么限制?
any limitation of getting splistitemcollection?
推荐答案
作为一种解决方法,我们可以从某个视图获取该集合.
As a workaround, we can get the collection from a certain view.
SPWeb web = site.OpenWeb();
SPList list = web.Lists["Shared Documents"];
//Getting only the view items - could be empty
SPListItemCollection itemCol = list.GetItems("FakeView");
http://rotemoss.blogspot.sg/2009/08/memory-problem-using .html
或者我们可以将SPQuery与ListItemCollectionPosition一起使用来批量获取列表项.
Or we can use SPQuery with ListItemCollectionPosition to get list items batch.
SPQuery query = new SPQuery();
query.RowLimit = 100; // we want to retrieve 100 items
query.ListItemCollectionPosition = prevItems.ListItemCollectionPosition; // starting at a previous position
SPListItemCollection items = SPContext.Current.List.GetItems(query);
// now iterate through the items collection
最好的问候,
这篇关于获取splistitemcollection时使服务器内存不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!