its*_*lur 7 asp.net memory-management external-process wkhtmltopdf
我在.NET 4.0中运行的C#Web应用程序中使用WkhtmltoPdf从HTML文件生成PDF.通常一切正常,除非HTML文件的大小低于250KB.一旦HTML文件大小超过该值,运行wkhtmltopdf.exe的进程就会产生如下异常.在任务管理器上,我已经看到wkhtmltopdf.exe进程的内存值没有超过40,096 K的值,我相信这就是为什么在这两者之间放弃进程的原因.
我们如何配置外部exes的内存限制可以增加?有没有其他方法可以解决这个问题?
更多信息:
当我直接从命令行运行转换时,PDF生成正常.所以,它不太可能成为WkhtmlToPdf的问题.
错误来自localhost.我在DEV服务器上尝试过相同的结果.
编辑:
更具体的异常消息: - 对于Process对象的MainModule属性,错误显示 - {"只有ReadProcessMemory或WriteProcessMemory请求的一部分已完成"},具有NativeErrorCode值 - 299.
例外:
> [Exception: Loading pages (1/6) [>
> ] 0% [======> ]
> 10% [======> ] 11%
> [=======> ] 13%
> [=========> ] 15%
> [==========> ] 18%
> [============> ] 20%
> [=============> ] 22%
> [==============> ] 24%
> [===============> ] 26%
> [=================> ] 29%
> [==================> ] 31%
> [===================> ] 33%
> [=====================> ] 35%
> [======================> ] 37%
> [========================> ] 40%
> [=========================> ] 42%
> [==========================> ] 44%
> [============================> ] 47%
> [=============================> ] 49%
> [==============================> ] 51%
> [============================================================] 100%
> Counting pages (2/6)
> [============================================================] Object
> 1 of 1 Resolving links (4/6)
> [============================================================] Object
> 1 of 1 Loading headers and footers (5/6)
> Printing pages (6/6) [>
> ] Preparing [=>
> ] Page 1 of 49 [==>
> ] Page 2 of 49 [===>
> ] Page 3 of 49 [====>
> ] Page 4 of 49 [======>
> ] Page 5 of 49 [=======>
> ] Page 6 of 49 [========>
> ] Page 7 of 49 [=========>
> ] Page 8 of 49 [==========>
> ] Page 9 of 49 [============>
> ] Page 10 of 49 [=============>
> ] Page 11 of 49 [==============>
> ] Page 12 of 49 [===============>
> ] Page 13 of 49 [================>
> ] Page 14 of 49 [==================>
> ] Page 15 of 49 [===================>
> ] Page 16 of 49 [====================>
> ] Page 17 of 49 [=====================>
> ] Page 18 of 49 [======================>
> ] Page 19 of 49 [========================>
> ] Page 20 of 49 [=========================>
> ] Page 21 of 49 [==========================>
> ] Page 22 of 49 [===========================>
> ] Page 23 of 49 [============================>
> ] Page 24 of 49 [==============================>
> ] Page 25 of 49 [===============================>
> ] Page 26 of 49 [=================================>
> ] Page 27 of 49 [==================================>
> ]
Run Code Online (Sandbox Code Playgroud)
我使用的代码:
var fileName = " - ";
var wkhtmlDir = ConfigurationManager.AppSettings[Constants.AppSettings.ExportToPdfExecutablePath];
var wkhtml = ConfigurationManager.AppSettings[Constants.AppSettings.ExportToPdfExecutablePath] + "\\wkhtmltopdf.exe";
var p = new Process();
string switches = "";
switches += "--print-media-type ";
switches += "--margin-top 10mm --margin-bottom 10mm --margin-right 5mm --margin-left 5mm ";
switches += "--page-size A4 ";
switches += "--disable-smart-shrinking ";
var startInfo = new ProcessStartInfo
{
CreateNoWindow = true,
FileName = wkhtml,
Arguments = switches + " " + url + " " + fileName,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardInput=true,
WorkingDirectory=wkhtmlDir
};
p.StartInfo = startInfo;
p.Start();
Run Code Online (Sandbox Code Playgroud)
调试器WkHtmlToPdf.exe进程的屏幕截图:

这就是您正在寻找的:
http://jobobjectwrapper.codeplex.com/
我找不到任何与“增加”进程内存限制有关的任何内容,尽管我听说人们使用 限制进程内存MaxWorkingSet,但我相信这仅适用于应用程序使用完所有可用内存后的虚拟内存。
作业对象是一个很好的起点,它们只是易于控制的流程的集合。
“通过这个库,您可以创建作业对象、创建流程并将其分配给作业、控制流程和作业限制,以及注册各种流程和作业相关的通知事件。”
这也可能有用:
| 归档时间: |
|
| 查看次数: |
1408 次 |
| 最近记录: |