Jump to content

Reduce Program Memory


Recommended Posts

Func _ReduceMemory()
   DllCall("psapi.dll", "int", "EmptyWorkingSet", "long", -1)
EndFunc

i dont know what this code is for. i thin it will reduce RAM memory to be less used for this program or process memory. or is it for good compression of exe? i need some useful info about it.

sorry for my spelling mistakes. its due to be fast !!!

Link to comment
Share on other sites

EmptyWorkingSet Function

Removes as many pages as possible from the working set of the specified process.

Syntax

BOOL WINAPI EmptyWorkingSet(

__in HANDLE hProcess

);

Parameters

hProcess

A 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 Value

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.

Remarks

You can also empty the working set by calling the SetProcessWorkingSetSize or SetProcessWorkingSetSizeEx function with the dwMinimumWorkingSetSize and dwMaximumWorkingSetSize parameters set to the value (SIZE_T)1.

Requirements

Client Requires Windows Vista, Windows XP, or Windows 2000 Professional.

Server Requires Windows Server 2008, Windows Server 2003, or Windows 2000 Server.

Header

Declared in Psapi.h.

Library

Use Psapi.lib.

DLL

Requires Psapi.dll.

i dont know what it will do and how it will reduce process memory

Edited by FastHelper

sorry for my spelling mistakes. its due to be fast !!!

Link to comment
Share on other sites

Removes as many pages as possible from the working set of the specified process.

Every process on a Windows computer has a designated amount of system memory assigned to it (which can be expanded as needed - isn't the kernel smart?). The system separates the designated memory into blocks called "pages" where the actual information is stored.

This function attempts to shrink the amount memory a particular process is using by looking at the "working set" (the current amount of memory allocated) of pages for that process and trying to cull any unused or empty pages from that working set, thus (hopefully) freeing up some memory to be allocated elsewhere.

Overall, it kinda looks like a bit of a hack to combat memory leaks in programs.

Link to comment
Share on other sites

@ jwseek

this is the perfect answer. can it/you do any other hack or trick for RAM Memory? anyway thanks for telling me all this information.

I can't, and if my limited knowledge of system memory allocation is above yours, I wouldn't recommend you do any of these hacks without reading quite a bit more about memory allocation/de-allocation and possibly trying to learn C/C++ for a week or two.

But if you're willing to risk your system (messing with this stuff can cause pretty serious problems), then start looking for memory functions in the Windows API documentation on that website I sent you and go nuts.

Edited by jwseek
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...