DocumentProperties increases handle count

DocumentProperties increases handle count

Post by David Roger » Sat, 22 Sep 2001 02:37:15



The second DocumentProperties() call below increments the
handle count (as shown by task manager on Windows 2000)
each time it is executed. Why is this? How can I get
around it, assuming I need to call this code many times?

HANDLE hPrinter;
char *pszDevice = m_csDevice.GetBuffer (128);

OpenPrinter (pszDevice, &hPrinter, NULL)
int nSize =
 DocumentProperties(NULL,hPrinter,pszDevice,NULL,NULL,0);

if (nSize != -1)
{
 if ((m_pDevMode = (PDEVMODE) malloc (nSize)) != NULL)
 {
   DocumentProperties
(NULL,hPrinter,pDevice,m_pDevMode,NULL,DM_OUT_BUFFER);
 }

Quote:}

ClosePrinter (hPrinter);

m_csDevice.ReleaseBuffer (-1);

 
 
 

DocumentProperties increases handle count

Post by Tony Edgecomb » Sat, 22 Sep 2001 21:00:19


It should be OK but I have seen a bug in some Lexmark printer drivers which
causes leaked handles, it could be the driver rather than your code.

Tony


Quote:> The second DocumentProperties() call below increments the
> handle count (as shown by task manager on Windows 2000)
> each time it is executed. Why is this? How can I get
> around it, assuming I need to call this code many times?

> HANDLE hPrinter;
> char *pszDevice = m_csDevice.GetBuffer (128);

> OpenPrinter (pszDevice, &hPrinter, NULL)
> int nSize =
>  DocumentProperties(NULL,hPrinter,pszDevice,NULL,NULL,0);

> if (nSize != -1)
> {
>  if ((m_pDevMode = (PDEVMODE) malloc (nSize)) != NULL)
>  {
>    DocumentProperties
> (NULL,hPrinter,pDevice,m_pDevMode,NULL,DM_OUT_BUFFER);
>  }
> }
> ClosePrinter (hPrinter);

> m_csDevice.ReleaseBuffer (-1);


 
 
 

DocumentProperties increases handle count

Post by David Roger » Sun, 23 Sep 2001 01:20:48


Bingo! Mega-Thank you's!

David

 
 
 

1. Rapid increase in handle count when deleting large directory using explorer

Hello
 I have observed this on a Windows 2000 server with SP3.
Using windows explorer if I try to delete a very large
directory ( approx 10 gb, which has nested sub
directories ) , then it can be seen from the task manager
that
   - The  File handles used by this process increases very
rapidly . This also causes the memory usage to grow
abnormally. In this case the File Handle increased to
approx 300,0000. Even after deletion , the file handles
are not released ( in this case the explorer.exe still
showed that approx 190,000 ) file handles were being used.
  Is this some kind of  a handle leak. Do I need to
install any pacth to prevent this

thanks

- Aniruddha

2. 3.12 on-line docs

3. SNMP Handle Count - what's normal?

4. Q: server-side imagemaps and Domino web server

5. System Handle count

6. Recommendations for books/study material for 70-175 VB6 Distrib.

7. System handls count increase

8. Game Timing Adventures

9. Increase Icon Count

10. Increasing file handles

11. QUick Reply Needed: How Do I Increase File Handles?

12. increasing file handles on win2k

13. Sharp increase in number of handles used by windows explorer