GetCurrentProcess返回当前进程Hprocess句柄2000以上系统用EmptyWorkingSet强制释放没被使用的内存页面The EmptyWorkingSet function removes as many pages as possible from the working set of the specified process. BOOL EmptyWorkingSet( HANDLE hProcess );Parameters hProcess [in] Handle to the process. The handle must have the PROCESS_QUERY_INFORMATION and PROCESS_SET_INFORMATION access rights. For more information, see Process Security and Access Rights. Return Values If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError.Res You can also use the SetProcessWorkingSetSize function to do what EmptyWorkingSet does if you pass it -1 for the minimum and maximum sizes.Requirements Client: Requires Windows XP, Windows 2000 Professional, or Windows NT Workstation 4.0. Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0. Header: Declared in Psapi.h. Library: Use Psapi.lib.
uses PsAPI;使用 EmptyWorkingSet
俺就知道一个
同样Free时,你只是声明了这块内存我不用了,剩下的系统会作,并不会立刻放掉。
当有别的程序要用这块内存的时候系统会将这块不用的内存划给它(有算法的,看看操作系统方面的书)。
BOOL EmptyWorkingSet(
HANDLE hProcess
);Parameters
hProcess
[in] Handle to the process. The handle must have the PROCESS_QUERY_INFORMATION and PROCESS_SET_INFORMATION access rights. For more information, see Process Security and Access Rights.
Return Values
If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError.Res
You can also use the SetProcessWorkingSetSize function to do what EmptyWorkingSet does if you pass it -1 for the minimum and maximum sizes.Requirements
Client: Requires Windows XP, Windows 2000 Professional, or Windows NT Workstation 4.0.
Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.
Header: Declared in Psapi.h.
Library: Use Psapi.lib.