简体   繁体   English

Spreadsheetlight Ram的用法

[英]Spreadsheetlight ram usage

I have a issue with SpreadSheetLight. 我对SpreadSheetLight有问题。 When I use SaveAs method it use about 1.2GB of RAM. 当我使用SaveAs方法时,它将使用约1.2GB的RAM。 I write about 6k records and the output file is only 6MB. 我写了大约6k条记录,输出文件只有6MB。 Someone else has this issue? 有人有这个问题吗?

The SaveAs code is here: SaveAs代码在这里:

using (var stream = new MemoryStream(Templates.BudgetTemplate))
{
    using (var doc = new SLDocument(stream))
    {
        doc.SelectWorksheet("Sheet");

        var i = 2; //first line is header
        var list = new List<object>(); //list initialization from DB Collection

        foreach (var item in list)
        {
            //doc.SetCellValue stuff, from A to AN columns

            i++;
        }

        doc.SaveAs(_path);
    }
}

It's probably to do with file size buffers. 这可能与文件大小缓冲区有关。 Just like running Excel will take up megabytes of RAM just so you can write an 20 kilobyte file, SpreadsheetLight does something similar. 就像运行Excel会占用数MB的RAM,以便您可以写入20 KB的文件一样,SpreadsheetLight也会执行类似的操作。

We're talking about Open XML spreadsheets, so technically speaking, the whole set of XML files is held in memory (at save time). 我们谈论的是Open XML电子表格,因此从技术上讲,整个XML文件集都保存在内存中(节省时间)。 For example, when zipping files, you hold the whole text file in memory, and then zip it into a smaller file. 例如,在压缩文件时,您将整个文本文件保存在内存中,然后将其压缩为一个较小的文件。 This is why SpreadsheetLight (and other libraries) take up more RAM than the final resulting file. 这就是为什么SpreadsheetLight(和其他库)占用比最终生成的文件更多的RAM的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM