On 30/01/2009 5:09 AM, Gustavo Tabares wrote:
Hi all,I'm having a problem when opening and enumerating a network resource many times. For example: i = 0 while i< 10000: handle = win32wnet.WNetOpenEnum(win32netcon.RESOURCE_CONNECTED, win32netcon.RESOURCETYPE_ANY, 0, None) partial_nr_list = win32wnet.WNetEnumResource(handle) while partial_nr_list: partial_nr_list = win32wnet.WNetEnumResource(handle) win32wnet.WNetCloseEnum(handle) i += 1 This eventually fails with: Traceback (most recent call last): File "C:\qtest.py", line 17, in<module> partial_nr_list = win32wnet.WNetEnumResource(handle) MemoryError: VirtualAlloc error in WNetEnumResource I took a look at the source for win32wnet.WNetEnumResource and it seems to be doing the correct thing in terms of memory. My application isn't doing the above exactly, however it does open/enumerate many times. Any ideas on what may be going on?
It appears if we change the memory-free calls in that function to: VirtualFree(lpBuffer, 0, MEM_RELEASE); // free the working buffer The leak goes away. Unless I hear it is a bad thing, I'll check it in... Cheers, Mark. _______________________________________________ python-win32 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-win32
