Error while opening document from bytes 'bad allocation'

This article was translated from English: Does it need improvement?
Translated
View the article in English

Le traitement de documents PDF volumineux peut être crucial pour certaines entreprises.

Lors de l'utilisation d'IronPDF pour charger un fichier PDF existant, IronPDF alloue une partie de la mémoire pour stocker le PDF chargé. Les applications fonctionnant en 32 bits ont une limite de mémoire de 2 Go par processus. Le chargement d'un fichier PDF de plus de 500 Mo peut dépasser cette limitation, entraînant une exception de 'mauvaise allocation'.

Message d'exception :

IronPdf.Exceptions.IronPdfNativeException: 'Error while opening document from bytes: 'bad allocation'.

Solution

Pour résoudre ce problème, veuillez configurer l'application pour qu'elle s'exécute en 64 bits. Cela permet à l'application d'accéder à un espace mémoire plus important, évitant ainsi l'erreur de 'mauvaise allocation'. Suivez ces étapes pour configurer votre projet Visual Studio pour cibler une plate-forme 64 bits :

// 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

En définissant la cible de la plate-forme sur x64, l'application peut utiliser la capacité de mémoire étendue d'un système 64 bits, évitant ainsi les problèmes d'allocation de mémoire liés aux fichiers PDF volumineux.

Curtis Chau
Rédacteur technique

Curtis Chau détient un baccalauréat en informatique (Université de Carleton) et se spécialise dans le développement front-end avec expertise en Node.js, TypeScript, JavaScript et React. Passionné par la création d'interfaces utilisateur intuitives et esthétiquement plaisantes, Curtis aime travailler avec des frameworks modernes ...

Lire la suite
Prêt à commencer?
Nuget Téléchargements 16,154,058 | Version : 2025.11 vient de sortir