Hi,
I'm using the windows function CreateFileW to get the filesize of files bigger then 2 Gb. But there seems to be a memory leak, or is it in my code? 44 bytes are lost every call.
Repeat
Notify("Ready?")
For Local i:Int = 1 To 3000
FileSizeEx("d:\temp\1.txt") ' change this to an existing file
Delay 1
Next
GCCollect()
Notify("Finished")
Forever
Extern "win32"
Function CreateFileW(lpFileName:Byte Ptr, dwDesiredAccess:int, dwShareMode:Int, lpSecurityAttributes:Byte Ptr, dwCreationDisposition:int, dwFlagsAndAttributes:int, hTemplateFile:int)
Function GetFileSizeEx(hFile:int, lpFileSize:Byte Ptr)
Function CloseHandle(hObject:Int)
EndExtern
Function FileSizeEx:Long(path:String) ' memory leak in createfileW()?
Global size:Long, handle:Int
handle=CreateFileW(path.ToWString(),GENERIC_READ,0,Null,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0)
If handle<>INVALID_HANDLE_VALUE
If GetFileSizeEx(handle, Varptr size) = 0 Then size = -1
CloseHandle(handle)
EndIf
handle = Null
Return size
EndFunction
|