ฉันกำลังคัดลอกไฟล์จากเซิร์ฟเวอร์ไปยังเครื่องในเครื่อง แปลงจากประเภทหนึ่งเป็นอีกประเภทหนึ่งแล้วคัดลอกกลับ แต่ฉันกำลังใช้หน่วยความจำเพิ่มขึ้นจากรหัสด้านล่าง ฉันจะกู้คืนทั้งหมดนี้ได้อย่างไร
async Task Rod(string fromDate, string toDate)
{
DatabaseLogic db = new DatabaseLogic();
var fileTypeId = "2";
var count = await db.GetDocumentsCount(fromDate, toDate);
var pageSize = Convert.ToInt32(AppConfiguration.GetSection("PageSize"));
int pageIndex = 0;
int processedCount = 0;
(string root, string fileTypeLocation) location = await locationAsync(fileTypeId);
var current = 0;
while (current <= count)
{
pageIndex++;
current = pageIndex * pageSize;
var documents = await db.GetRodDocuments(fromDate, toDate,
pageIndex, pageSize);
await Parallel.ForEachAsync(documents, async (document, token) =>
{
var filename = $"C:\\app\\" + document.File;
var filesAndDirectores = await ManageFilesAndDirectories(filename,
"rod", ".djvu");
await ProcessFiles(filesAndDirectores.docType,
filesAndDirectores.sourceFilename,
filesAndDirectores.destinationDirectory,
filesAndDirectores.localFile);
});
documents = null;
}
}
โปรไฟล์หน่วยความจำ: