从字节 "坏分配 "打开文档时出错
This article was translated from English: Does it need improvement?
TranslatedView the article in English
处理大型 PDF 文档对某些企业至关重要。
使用 IronPDF 加载现有 PDF 文件时,IronPDF 分配一部分内存来存储已加载的 PDF。 在32位上运行的应用程序每个进程的内存限制为2 GB。 加载大于 500 MB 的 PDF 文件可能会超过此限制,导致 'bad allocation' 异常。
异常信息:
IronPdf.Exceptions.IronPdfNativeException: 'Error while opening document from bytes: 'bad allocation'.解决方案
要解决此问题,请将应用程序设置为在64位上运行。 这允许应用程序访问更大的内存空间,避免 'bad allocation' 错误。 请按照以下步骤配置您的 Visual Studio 项目以定位 64 位平台:
// Open your project in Visual Studio
// In the Solution Explorer, right-click on your project and select 'Properties'
// Navigate to the 'Build' tab
// Select 'x64' from the 'Platform target' dropdown
<PropertyGroup>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
// Save your changes and rebuild the project// Open your project in Visual Studio
// In the Solution Explorer, right-click on your project and select 'Properties'
// Navigate to the 'Build' tab
// Select 'x64' from the 'Platform target' dropdown
<PropertyGroup>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
// Save your changes and rebuild the project' Open your project in Visual Studio
' In the Solution Explorer, right-click on your project and select 'Properties'
' Navigate to the 'Build' tab
' Select 'x64' from the 'Platform target' dropdown
(Of PropertyGroup) (Of PlatformTarget) x64</PlatformTarget> </PropertyGroup>
' Save your changes and rebuild the project$vbLabelText $csharpLabel
通过将平台目标设置为 x64,应用程序可以利用 64 位系统的扩展内存容量,从而防止与大型 PDF 文件相关的内存分配问题。
准备开始了吗?
Nuget 下载 16,685,821 | 版本: 2025.12 刚刚发布






