Comments (5)
How do you know it is never cleared from memory? The garbage collection should remove it.
from pdfsharp.
Thread.Sleep(5000);
using (PdfDocument pdfDocument = PdfReader.Open("a.pdf", PdfDocumentOpenMode.Import))
{
pdfDocument.Dispose();
}
Console.WriteLine("pdfDocument should be closed and removed from memory");
Console.ReadKey();
In my understanding, when the program reaches Console.Writeline
, GC should remove pdfDocument from memory.
from pdfsharp.
GC runs when it runs - unless you invoke it explicitly.
At WriteLine the object should be disposed, but GC will not run automatically at every Dispose.
Application memory will not shrink even if heap has large unused areas.
What do you get when you do Import/Dispose 10 times in a loop?
Code to invoke GC:
GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
GC.Collect();
from pdfsharp.
Thread.Sleep(5000);
for(int i = 0; i < 10; i++)
{
using (PdfDocument pdfDocument = PdfReader.Open("file.pdf", PdfDocumentOpenMode.Import))
{
pdfDocument.Dispose();
}
}
GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
GC.Collect();
Console.WriteLine("pdfDocument should be closed and removed from memory");
Console.ReadKey();
Running GC manually does not seems to make any diffrence.
file.pdf is 489MB
from pdfsharp.
So it is about 500 MB after one cycle and about 500 MB after 10 cycles.
Looks as if garbage collection works as it should, even though it does not occur when you expect it.
from pdfsharp.
Related Issues (20)
- Does anyone know how to remove image from a PDF? HOT 2
- When I reference PdfSharp, why is a directory named de created in the output directory? HOT 7
- Working with coordinates HOT 1
- Corrupted File Error HOT 4
- Deleted page not "really" deleted HOT 2
- Opening PDF from Google spreadsheet fails with a "Name required" exception HOT 3
- Link to fix to Accessibility StructureBuilder.cs does not exist, might be related to our issue. HOT 2
- How to resolve CID Text or transfer to Unicode?
- System.InvalidOperationException: 'Stream cannot be read. Please send us the PDF file so that we can fix this (issues (at) pdfsharp.net).' HOT 2
- Trimming self-contained deployment fails with an exception HOT 2
- XGraphics.FromPdfPage disposes object returned by static method HOT 7
- Incorrect parsing of REVERSE SOLIDUS in literal string
- 【Suggestion】Support grid layout for easier PDF document creation. HOT 3
- [Suggestion] Add support of annotation flags to signature field
- Png Decode Error With BitsPerComponent==4 HOT 2
- [Suggestion] Avoid hardcoded font name in MigraDoc.Rendering.Rendering.ImageRenderer.cs HOT 1
- When exporting PDF, all Chinese characters become squares HOT 2
- correct datetime format in XMP Metadata for CreateDate/ModifyDate
- Certain PNG images are skewed when rendering in Core build of PDFsharp HOT 9
- 异常:The encryption revision value must be 6 for encryption version 5.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdfsharp.