Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am Using System.Printing library in my application with .net framework 3.5. When i Print job on any printer using PrintQueue.AddJob memory gets increased and doesnt releases it. Memory is released only if the application is closed.
If i print more than 10 jobs then my application uses all the memory of my computer and finally everything gets slows down.
I obeserved the memory usage goes to 2GB, which is not acceptable.
After investigation i found that Memory gets increased when PrintqQueue.AddJob method is invoked.

Here is my sample Code for printing:

C#
PrintServer printServer = new PrintServer(@"\\sshinde");
PrintQueue PrintQ = new PrintQueue(printServer, "HP_Printer", PrintSystemDesiredAccess.AdministratePrinter);
PrintQ.AddJob("xyz", @"C:\ProgramData\MyComapny\PrintSoftware\Config\Print_Manager\INPUT\d7a8a71b-4e73-43ec-8ee9-bbe24b3ba2cb.xps", false);
Posted
Updated 8-May-14 1:04am
v2
Comments
[no name] 8-May-14 6:50am    
And? Did you have some sort of a question? Are you properly disposing your objects so that the GC and collect them? Is the GC running at all? How exactly are you determining that the memory is not being released? What is it about your uncompilable sample code are we supposed to be looking at?
sagar_253 8-May-14 7:05am    
Yes i have tried with GC but still the memory is not released, with the help of task manager i am noting down the increase in the memory, it keeps on increasing when i add more jobs.
I have updated the code, now you can check.
[no name] 8-May-14 7:10am    
Okay so your only evidence is that task manager shows that memory is increasing? Did you know that task manager lies? Do you know how the garbage collector works? You most likely do not have any kind of a problem at all.
Chase Viking 9-Oct-20 8:43am    
Why do people like you have to reply like a dick?

1 solution

The solution I would have suggested has already been posted to your cross-post question on SO
http://stackoverflow.com/questions/23537009/system-printing-printqueue-addjob-methods-consumes-memory-and-doesnt-releases-on[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900