By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,190 Members | 772 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,190 IT Pros & Developers. It's quick & easy.

2 Gig Print Spooler process

P: n/a
I'm printing a directory of about 500 multi-page tifs to a high speed
printer and the spooler process is killing me!!!

here is a little code.....

Public Function PrintImage(ByVal SourceFile As String) As Boolean

Try
ImageToPrint = FromFile(SourceFile)

PageNumber = 0
ImagePages = ImageToPrint.GetFrameCount(FrameDimension.Page())
Catch ex As Exception
General.WriteToEventLog(ex.ToString, "Print Class",
EventLogEntryType.Error)
End Try

Try

PDocument.DocumentName = SourceFile
PDocument.Print()

Catch ex As Exception
General.WriteToEventLog(ex.ToString, "Print Class",
EventLogEntryType.Error)
Return False
End Try

Return True

End Function

Then the event on the global variable PDocument is being raised for the
pages....

Private Sub PagePrintFunction(ByVal sender As Object, ByVal e As
PrintPageEventArgs) Handles PDocument.PrintPage
Try
ImageToPrint.SelectActiveFrame(FrameDimension.Page , PageNumber)

PageNumber = PageNumber + 1

e.Graphics.DrawImage(ImageToPrint, 0, 0,
(e.PageSettings.PaperSize.Width - 40), (e.PageSettings.PaperSize.Height -
50))

If PageNumber < ImagePages Then
e.HasMorePages = True
End If
Catch ex As Exception
General.WriteToEventLog(ex.ToString, "Print Class",
EventLogEntryType.Error)
End Try
End Sub

This is not only really slow with larger images but as stated in the title,
my print spooler process turns into a 2 Gig memory monster after only about
160 images!!!!!!!!! Does anyone have a better solution or can tweak the
code? I'm kinda at my wits end over this. I've tried creating and
disposing of the PDocument variable in my loop that prints each file and
still the process grows.

MANY Thanks
Scott

Jul 24 '06 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Scott M wrote:
I'm printing a directory of about 500 multi-page tifs to a high speed
printer and the spooler process is killing me!!!

here is a little code.....

Public Function PrintImage(ByVal SourceFile As String) As Boolean

Try
ImageToPrint = FromFile(SourceFile)

PageNumber = 0
ImagePages = ImageToPrint.GetFrameCount(FrameDimension.Page())
Catch ex As Exception
General.WriteToEventLog(ex.ToString, "Print Class",
EventLogEntryType.Error)
End Try

Try

PDocument.DocumentName = SourceFile
PDocument.Print()

Catch ex As Exception
General.WriteToEventLog(ex.ToString, "Print Class",
EventLogEntryType.Error)
Return False
End Try

Return True

End Function

Then the event on the global variable PDocument is being raised for the
pages....

Private Sub PagePrintFunction(ByVal sender As Object, ByVal e As
PrintPageEventArgs) Handles PDocument.PrintPage
Try
ImageToPrint.SelectActiveFrame(FrameDimension.Page , PageNumber)

PageNumber = PageNumber + 1

e.Graphics.DrawImage(ImageToPrint, 0, 0,
(e.PageSettings.PaperSize.Width - 40), (e.PageSettings.PaperSize.Height
- 50))

If PageNumber < ImagePages Then
e.HasMorePages = True
End If
Catch ex As Exception
General.WriteToEventLog(ex.ToString, "Print Class",
EventLogEntryType.Error)
End Try
End Sub

This is not only really slow with larger images but as stated in the
title, my print spooler process turns into a 2 Gig memory monster after
only about 160 images!!!!!!!!! Does anyone have a better solution or
can tweak the code? I'm kinda at my wits end over this. I've tried
creating and disposing of the PDocument variable in my loop that prints
each file and still the process grows.

MANY Thanks
Scott
Just a quick thought.... I believe your problem is because the spooler
isn't purged until the last page is printed. Have you tried dividing
the overall print task into smaller numbers of pages, and then calling
the print function several times? You'd have to handle the Start-Page
for each call in this case, but it might work.... Then again, you might
just end up with several smaller spooler tasks that add-up to be 2 gig,
but I would at least expect each spooler process to be deleted once all
the pages in each process had been printed.

Anyone else tried this?

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Jul 25 '06 #2

P: n/a
Hi Scott,

Thanks for your post!

Does your tif file have 500 frames or do you have 500 files in a directory
for printing?

ShaneO's reply seems make sense, you may give it try and feedback the
result here.

Regarding this issue, I recommend you try to use some existing softwares
that can read these tif files for printing, can this problem be reproduced?
I suspect it may be a bug of spooler process since your code snippet is
really simple.

Anyway, I will wait for your feedback. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 25 '06 #3

P: n/a
The Printimage function gets called 500 times for tiffs that have about 10 -
30 pages in each. I haven't installed the service on any other machines to
see if it will konk out the server there, either.

I really stinks to have to restart the spooler and to restart the machine
after only printing 100 tiffs.

And as far as other software, Jeff. What do you suggest? This is a server
side process for a production orientated environment so I can't have much
downtime.

Thanks
Scott
""Jeffrey Tan[MSFT]"" <je***@online.microsoft.comwrote in message
news:zP**************@TK2MSFTNGXA01.phx.gbl...
Hi Scott,

Thanks for your post!

Does your tif file have 500 frames or do you have 500 files in a directory
for printing?

ShaneO's reply seems make sense, you may give it try and feedback the
result here.

Regarding this issue, I recommend you try to use some existing softwares
that can read these tif files for printing, can this problem be
reproduced?
I suspect it may be a bug of spooler process since your code snippet is
really simple.

Anyway, I will wait for your feedback. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
Jul 25 '06 #4

P: n/a
Scott M wrote:
The Printimage function gets called 500 times for tiffs that have
about 10 - 30 pages in each. I haven't installed the service on any
other machines to see if it will konk out the server there, either.

I really stinks to have to restart the spooler and to restart the
machine after only printing 100 tiffs.

And as far as other software, Jeff. What do you suggest? This is a
server side process for a production orientated environment so I
can't have much downtime.
Could you monitor the size of the spooler directory and wait for it to go
down a bit before adding more print jobs to it?

Andrew
Jul 25 '06 #5

P: n/a
It doesn't go down. even after the service that spools the images is
restarted.

"Andrew Morton" <ak*@in-press.co.uk.invalidwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Scott M wrote:
>The Printimage function gets called 500 times for tiffs that have
about 10 - 30 pages in each. I haven't installed the service on any
other machines to see if it will konk out the server there, either.

I really stinks to have to restart the spooler and to restart the
machine after only printing 100 tiffs.

And as far as other software, Jeff. What do you suggest? This is a
server side process for a production orientated environment so I
can't have much downtime.

Could you monitor the size of the spooler directory and wait for it to go
down a bit before adding more print jobs to it?

Andrew
Jul 25 '06 #6

P: n/a
Hi Scott,

Based on my experience, any type of image viewer software will have print
function build-in. You may choose one supports tif file, and try to print
the tif files one by one. I am not sure if mspaint.exe supports tif image,
can you give it a try?

Looking at the issue's nature, it is hard for us to give it a reproduce on
my side. It would require intensive troubleshooting which would be done
quickly and effectively with direct assistance from a Microsoft Support
Professional through Microsoft Product Support Services. They may perform
some remote debugging to your machine to identify the root cause.

You can contact Microsoft Product Support directly to discuss additional
support options you may have available, by contacting us at 1-(800)936-5800
or by choosing one of the options listed at
http://www.microsoft.com/services/mi...v_support.mspx

Finally, if you want to troubleshoot the spooler process memory issue, it
is helpful to use UMDH.EXE from windbg to. The tool can be used to obtain
call stack information of various memory block allocation of a process.
Please refer to below for more information:
"Umdhtools.exe: How to Use Umdh.exe to Find Memory Leaks"
http://support.microsoft.com/kb/268343/

Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 26 '06 #7

P: n/a
>Scott M wrote:
>>The Printimage function gets called 500 times for tiffs that have
about 10 - 30 pages in each. I haven't installed the service on any
other machines to see if it will konk out the server there, either.

I really stinks to have to restart the spooler and to restart the
machine after only printing 100 tiffs.

And as far as other software, Jeff. What do you suggest? This is
a server side process for a production orientated environment so I
can't have much downtime.
"Andrew Morton" wrote
>Could you monitor the size of the spooler directory and wait for it
to go down a bit before adding more print jobs to it?
Scott M wrote:
It doesn't go down...
What, not even after the images have been printed? I'm suggesting that
rather than try to sent umpteen gigabytes all in one go, you give the
printer (and print spooler) a chance to catch up/breathe. And avoid filling
up the disk the spool folder resides on.
...even after the service that spools the images is
restarted.
The print spooler service should not delete the files in the spool folder
just because it's been restarted.

The spool folder location is in the registry at
HKLM\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Print\Printers\DefaultSpoolDirec tory
(and other locations; I can't remember which one to set to change it).

Andrew
Jul 26 '06 #8

P: n/a
This actually sounds like a bug in the Printimage function. Does this
function close each print job properly. By this I mean are the spool files
closed once they have been created. I have seen image processing programs
not properly close the images when they are done with them.

Mike Ober.
"Scott M" <sc*****@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
The Printimage function gets called 500 times for tiffs that have about
10 - 30 pages in each. I haven't installed the service on any other
machines to see if it will konk out the server there, either.

I really stinks to have to restart the spooler and to restart the machine
after only printing 100 tiffs.

And as far as other software, Jeff. What do you suggest? This is a
server side process for a production orientated environment so I can't
have much downtime.

Thanks
Scott
""Jeffrey Tan[MSFT]"" <je***@online.microsoft.comwrote in message
news:zP**************@TK2MSFTNGXA01.phx.gbl...
>Hi Scott,

Thanks for your post!

Does your tif file have 500 frames or do you have 500 files in a
directory
for printing?

ShaneO's reply seems make sense, you may give it try and feedback the
result here.

Regarding this issue, I recommend you try to use some existing softwares
that can read these tif files for printing, can this problem be
reproduced?
I suspect it may be a bug of spooler process since your code snippet is
really simple.

Anyway, I will wait for your feedback. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
================================================= =
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
================================================= =
This posting is provided "AS IS" with no warranties, and confers no
rights.

Jul 26 '06 #9

P: n/a
I'm not too sure what you mean. I've changed the code considerably since
I've last posted it (trying to figure out what is happening). Installed new
print drivers and messed with settings on the printer with our own hardware
support (Direct printing instead of spooling the print jobs)

It's just a huge enigma to me. Even after the application hasn't been
printing for over two hours now the spoolersv.exe process stands at
1,140,324 K in task manager. the users printed about 700 single page tiff
files today. Here is the code that printed the images.

Private Sub PagePrintFunction(ByVal sender As Object, ByVal e As
PrintPageEventArgs)
Static Dim PageNumber As Integer = 0

Try
ImageToPrint.SelectActiveFrame(FrameDimension.Page , PageNumber)

PageNumber += 1

e.Graphics.DrawImage(ImageToPrint, New RectangleF(0, 0,
(e.PageSettings.PaperSize.Width - 40), (e.PageSettings.PaperSize.Height -
50)))

If PageNumber < ImagePages Then
e.HasMorePages = True
Else
e.HasMorePages = False
e.Graphics.Dispose()
PageNumber = 0
End If

Catch ex As Exception
General.WriteToEventLog("PagePrintFunction" & vbCrLf &
ex.ToString, "Print Class", EventLogEntryType.Error)
Throw ex
End Try
End Sub

Public Function PrintImage(ByVal SourceFile As String) As Boolean

Try
ImageToPrint = FromFile(SourceFile)

ImagePages = ImageToPrint.GetFrameCount(FrameDimension.Page())
Catch ex As Exception
General.WriteToEventLog("Getting Image Frames: " & vbCrLf &
ex.ToString, "Print Class", EventLogEntryType.Error)
End Try

Try
Using PDocument As New PrintDocument

PDocument.PrinterSettings.PrinterName = PrinterName
PDocument.DocumentName = SourceFile

AddHandler PDocument.PrintPage, AddressOf PagePrintFunction

PDocument.Print()
End Using

Catch ex As Exception
General.WriteToEventLog("Print Document: " & vbCrLf &
ex.ToString, "Print Class", EventLogEntryType.Error)
Return False
End Try

Return True

End Function

Public Sub PrintFolderContents()

Dim ExtensionFilter As String = "*." & Filter
Dim FileNameList As String() = Directory.GetFiles(Folder,
ExtensionFilter)

Try
General.WriteToEventLog("Starting to print " & Folder, "Print
Class", EventLogEntryType.Information)

FileNameList = Directory.GetFiles(Folder, ExtensionFilter)

Array.Sort(FileNameList)

If _ToggleArchiveBit Then
turnOffSwapFileBits(FileNameList)
End If
Catch ex As Exception
General.WriteToEventLog(ex.ToString, "Print Class",
EventLogEntryType.Error)
End Try

Try

For i As Integer = 0 To FileNameList.Length - 1
If PrintImage(FileNameList(i)) Then
If _ToggleArchiveBit Then
turnOnAttributeBit(FileNameList(i))
End If
Else
General.WriteToEventLog("File " & FileNameList(i) & "
did not properly Print.", "Print Class", EventLogEntryType.Warning)
End If

Next

Catch ex As Exception
General.WriteToEventLog(ex.ToString, "Print Class",
EventLogEntryType.Error)
Finally
If Not ImageToPrint Is Nothing Then
ImageToPrint.Dispose()
End If
End Try

End Sub

The speed at which the jobs are pushed into the printer is less then optimal
as well.
"Michael D. Ober" <obermd.@.alum.mit.edu.nospamwrote in message
news:eL**************@TK2MSFTNGP02.phx.gbl...
This actually sounds like a bug in the Printimage function. Does this
function close each print job properly. By this I mean are the spool
files closed once they have been created. I have seen image processing
programs not properly close the images when they are done with them.

Mike Ober.
"Scott M" <sc*****@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>The Printimage function gets called 500 times for tiffs that have about
10 - 30 pages in each. I haven't installed the service on any other
machines to see if it will konk out the server there, either.

I really stinks to have to restart the spooler and to restart the machine
after only printing 100 tiffs.

And as far as other software, Jeff. What do you suggest? This is a
server side process for a production orientated environment so I can't
have much downtime.

Thanks
Scott
""Jeffrey Tan[MSFT]"" <je***@online.microsoft.comwrote in message
news:zP**************@TK2MSFTNGXA01.phx.gbl...
>>Hi Scott,

Thanks for your post!

Does your tif file have 500 frames or do you have 500 files in a
directory
for printing?

ShaneO's reply seems make sense, you may give it try and feedback the
result here.

Regarding this issue, I recommend you try to use some existing softwares
that can read these tif files for printing, can this problem be
reproduced?
I suspect it may be a bug of spooler process since your code snippet is
really simple.

Anyway, I will wait for your feedback. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
================================================ ==
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach
the
most efficient resolution. The offering is not appropriate for
situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are
best
handled working with a dedicated Microsoft Support Engineer by
contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
================================================ ==
This posting is provided "AS IS" with no warranties, and confers no
rights.

Jul 26 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.