Hi,
I have a problem with the URLDownloadToFile API reserving a large chunk of memory, and I can't figure out how to free it. My program is an app that runs in the background, downloading multiple Excel workbooks (.xls) from a web page.
When the first file is downloaded, the memory usage of the process jumps from ~5Mb to ~70Mb and stays there. The memory consumption doesn't increase with subsequent calls to the API.
Here is the relevant code:
Worthy of noticing, that the exact same behavior is elicited when calling the API with null arguments, as instructed on some websites:
Does anybody have any idea why this is happening? Any tidbit of information would be valuable.
I have a problem with the URLDownloadToFile API reserving a large chunk of memory, and I can't figure out how to free it. My program is an app that runs in the background, downloading multiple Excel workbooks (.xls) from a web page.
When the first file is downloaded, the memory usage of the process jumps from ~5Mb to ~70Mb and stays there. The memory consumption doesn't increase with subsequent calls to the API.
Here is the relevant code:
Code:
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" ( _
ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Private Const ERROR_SUCCESS As Long = 0
Private Const BINDF_GETNEWESTVERSION As Long = &H10
Private Const INTERNET_FLAG_RELOAD As Long = &H80000000
Public Function bHTTPDownloadFile(sSourceUrl As String, _
sLocalFile As String) As Boolean
'Download the file. BINDF_GETNEWESTVERSION forces the API to download from the specified source.
'Passing 0& as dwReserved causes the locally-cached copy to be downloaded, if available. If the API
'returns ERROR_SUCCESS (0), DownloadFile returns True.
bHTTPDownloadFile = URLDownloadToFile(0&, _
sSourceUrl, _
sLocalFile, _
BINDF_GETNEWESTVERSION, _
0&) = ERROR_SUCCESS
End Function
Worthy of noticing, that the exact same behavior is elicited when calling the API with null arguments, as instructed on some websites:
Code:
URLDownloadToFile(0, sSourceUrl, sLocalFile, 0, 0)
Does anybody have any idea why this is happening? Any tidbit of information would be valuable.