私はこのようなコードを持っています:
public bool Set(IEnumerable<WhiteForest.Common.Entities.Projections.RequestProjection> requests)
{
var documentSession = _documentStore.OpenSession();
//{
try
{
foreach (var request in requests)
{
documentSession.Store(request);
}
//requests.AsParallel().ForAll(x => documentSession.Store(x));
documentSession.SaveChanges();
documentSession.Dispose();
return true;
}
catch (Exception e)
{
_log.LogDebug("Exception in RavenRequstRepository - Set. Exception is [{0}]", e.ToString());
return false;
}
//}
}
このコードは何度も呼び出されます。通過した約50,000のドキュメントに到達した後、OutOfMemoryExceptionが発生します。理由は何ですか?おそらくしばらくして、新しいDocumentStoreを宣言する必要がありますか?
ありがとうございました
**
- アップデート:
**
最終的に、Batch /PatchAPIを使用して必要な更新を実行しました。ここでディスカッションを見ることができます:https://groups.google.com/d/topic/ravendb/3wRT9c8Y-YE/discussion
基本的に、オブジェクトの1つのプロパティを更新するだけでよく、すべてのオブジェクトをJSONに再シリアル化することについてのayendesのコメントを検討した後、次のようにしました。
internal void Patch()
{
List<string> docIds = new List<string>() { "596548a7-61ef-4465-95bc-b651079f4888", "cbbca8d5-be45-4e0d-91cf-f4129e13e65e" };
using (var session = _documentStore.OpenSession())
{
session.Advanced.DatabaseCommands.Batch(GenerateCommands(docIds));
}
}
private List<ICommandData> GenerateCommands(List<string> docIds )
{
List<ICommandData> retList = new List<ICommandData>();
foreach (var item in docIds)
{
retList.Add(new PatchCommandData()
{
Key = item,
Patches = new[] { new Raven.Abstractions.Data.PatchRequest () {
Name = "Processed",
Type = Raven.Abstractions.Data.PatchCommandType.Set,
Value = new RavenJValue(true)
}}});
}
return retList;
}
お役に立てれば ...
どうもありがとう。