O
objectref
Hi,
i found on the net something that it has to do with the large
working set of a .net application, describing the process of
the CLR loading and all this stuff.
It seems that every time CLR needs memory, it requests a bit more
than it actually needs so with the below simple code we can
"trim" the extra memory and keep the working set down.
public static void SetWorkingSet(int lnMaxSize, int lnMinSize)
{
System.Diagnostics.Process loProcess =
System.Diagnostics.Process.GetCurrentProcess();
loProcess.MaxWorkingSet = (IntPtr) lnMaxSize;
loProcess.MinWorkingSet = (IntPtr) lnMinSize;
//long lnValue = loProcess.WorkingSet; // see what the actual value
}
I made some tests of a software of mine that we work here (in-house) in my
company
and i saw that from 30+ MB of memory that my app needed all this time,
with the above code it occupied less than 10...
To accomplish that, i was "forced" to call this routine in every form
load/unload event
and the working set really kept down this way.
In theory, all this code does is to call the repsective Windows API function
so it in turn
trim the application workign set.
If it cannot trim down to the values specified, it just do the best it can.
I was wondering if this will cause any runtime (or other) problems,
can anyone help on this ??
Thanks in advance,
objectref
i found on the net something that it has to do with the large
working set of a .net application, describing the process of
the CLR loading and all this stuff.
It seems that every time CLR needs memory, it requests a bit more
than it actually needs so with the below simple code we can
"trim" the extra memory and keep the working set down.
public static void SetWorkingSet(int lnMaxSize, int lnMinSize)
{
System.Diagnostics.Process loProcess =
System.Diagnostics.Process.GetCurrentProcess();
loProcess.MaxWorkingSet = (IntPtr) lnMaxSize;
loProcess.MinWorkingSet = (IntPtr) lnMinSize;
//long lnValue = loProcess.WorkingSet; // see what the actual value
}
I made some tests of a software of mine that we work here (in-house) in my
company
and i saw that from 30+ MB of memory that my app needed all this time,
with the above code it occupied less than 10...
To accomplish that, i was "forced" to call this routine in every form
load/unload event
and the working set really kept down this way.
In theory, all this code does is to call the repsective Windows API function
so it in turn
trim the application workign set.
If it cannot trim down to the values specified, it just do the best it can.
I was wondering if this will cause any runtime (or other) problems,
can anyone help on this ??
Thanks in advance,
objectref