sagar shinde

sagar shinde

  • NA
  • 17
  • 12.3k

System.Printing Printqueue.AddJob method not releases memory

May 8 2014 4:47 AM

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:
PrintServer printServer = newPrintServer(@"\\sshinde");
PrintQueue PrintQ = newPrintQueue(printServer, "HP_Printer", PrintSystemDesiredAccess.AdministratePrinter);
PrintQ.AddJob("xyz", @"C:\ProgramData\MyComapny\PrintSoftware\Config\Print_Manager\INPUT\d7a8a71b-4e73-43ec-8ee9-bbe24b3ba2cb.xps", false);