C ++ InternetOpenUrlW - 内存使用情况

时间:2015-07-07 20:42:13

标签: c++ memory visual-studio-2013

更新:感谢您的回复。我想我明白为什么会发生这种情况以及我可能会尝试减少内存使用量。此外,是的,我使用InternetCloseHandle,但它不会改变内存使用情况。

我正在编写一个简单的C ++应用程序。其中一种方法是将非常小的文件下载到内存中并将其作为字符串返回。

然而,我注意到代码的一个特定部分使我的程序占用了7倍以上的内存(从1mb到7mb),我觉得很奇怪,我想避免它。下面是一个代码片段,解释了内存使用率峰值何时发生:

//InternetOpenW() doesnt trigger memory usage spike.
hOpen = InternetOpenW(L"MyAgent", NULL, NULL, NULL, NULL);
if (!hOpen) return NULL;

//When InternetOpenUrlW() runs, the memory spikes.
hFile = InternetOpenUrlW(hOpen, szUrl, NULL, NULL, INTERNET_FLAG_RELOAD | INTERNET_FLAG_DONT_CACHE, NULL);
if (!hFile) 
{
    InternetCloseHandle(hOpen);
    return NULL;
}

内存使用量永远不会下降,所以我想知道是否有可能对此做些什么。

有人建议我在执行InternetOpenUrlW()时检查加载的模块。以下是此步骤仅加载的模块的输出。但是,我不会撒谎,我不知道这是什么意思或我应该怎么做。

'Application.exe' (Win32): Loaded 'C:\Windows\SysWOW64\mswsock.dll'. Cannot find or open the PDB file.
'Application.exe' (Win32): Loaded 'C:\Windows\SysWOW64\IPHLPAPI.DLL'. Cannot find or open the PDB file.
'Application.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winnsi.dll'. Cannot find or open the PDB file.
'Application.exe' (Win32): Loaded 'C:\Windows\SysWOW64\wship6.dll'. Cannot find or open the PDB file.
'Application.exe' (Win32): Loaded 'C:\Windows\SysWOW64\api-ms-win-downlevel-shlwapi-l2-1-0.dll'. Cannot find or open the PDB file.
'Application.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dnsapi.dll'. Cannot find or open the PDB file.
'Application.exe' (Win32): Loaded 'C:\Windows\SysWOW64\clbcatq.dll'. Cannot find or open the PDB file.
'Application.exe' (Win32): Loaded 'C:\Windows\SysWOW64\oleaut32.dll'. Cannot find or open the PDB file.
'Application.exe' (Win32): Loaded 'C:\Windows\SysWOW64\WSHTCPIP.DLL'. Cannot find or open the PDB file.
'Application.exe' (Win32): Loaded 'C:\Windows\SysWOW64\netprofm.dll'. Cannot find or open the PDB file.
'Application.exe' (Win32): Loaded 'C:\Windows\SysWOW64\nlaapi.dll'. Cannot find or open the PDB file.
'Application.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dhcpcsvc6.dll'. Cannot find or open the PDB file.
'Application.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rasadhlp.dll'. Cannot find or open the PDB file.
'Application.exe' (Win32): Loaded 'C:\Windows\SysWOW64\urlmon.dll'. Cannot find or open the PDB file.
'Application.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dhcpcsvc.dll'. Cannot find or open the PDB file.
'Application.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptsp.dll'. Cannot find or open the PDB file.
'Application.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rsaenh.dll'. Cannot find or open the PDB file.
'Application.exe' (Win32): Loaded 'C:\Windows\SysWOW64\RpcRtRemote.dll'. Cannot find or open the PDB file.
'Application.exe' (Win32): Loaded 'C:\Windows\SysWOW64\npmproxy.dll'. Cannot find or open the PDB file.
'Application.exe' (Win32): Loaded 'C:\Windows\SysWOW64\FWPUCLNT.DLL'. Cannot find or open the PDB file.
'Application.exe' (Win32): Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.18807_none_41e554362bd82458\comctl32.dll'. Cannot find or open the PDB file.
'Application.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ws2_32.dll'. Cannot find or open the PDB file.
'Application.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\ws2_32.dll'

0 个答案:

没有答案