By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,435 Members | 2,939 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,435 IT Pros & Developers. It's quick & easy.

Reducing Mem Usage

P: n/a
As everybody points out, the best way to reduce the memory footprint of a
..net application is to minimize it and restore it. This can make my app go
from 40Mb of usage to about 3Mb of usage. Of course it will grow again
gradually...

My clients have requested that I somehow automate this... so that it
achieves the same result periodically without them having to minimize the
application. They claim otherwise it's difficult for them to monitor their
users' machines for resource utilization.

Any ideas?

TIA,
John
Nov 16 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
John,

You can call the SetProcessWorkingSetSizeEx API function, passing in -1
for the dwMinimumWorkingSetSize and dwMaximumWorkingSetSize parameters to do
this.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John Wood" <sp**@isannoying.com> wrote in message
news:eh**************@TK2MSFTNGP12.phx.gbl...
As everybody points out, the best way to reduce the memory footprint of a
.net application is to minimize it and restore it. This can make my app go from 40Mb of usage to about 3Mb of usage. Of course it will grow again
gradually...

My clients have requested that I somehow automate this... so that it
achieves the same result periodically without them having to minimize the
application. They claim otherwise it's difficult for them to monitor their
users' machines for resource utilization.

Any ideas?

TIA,
John

Nov 16 '05 #2

P: n/a
Ooh coolio, thanks!
Very useful information.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Ob**************@TK2MSFTNGP09.phx.gbl...
John,

You can call the SetProcessWorkingSetSizeEx API function, passing in -1 for the dwMinimumWorkingSetSize and dwMaximumWorkingSetSize parameters to do this.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John Wood" <sp**@isannoying.com> wrote in message
news:eh**************@TK2MSFTNGP12.phx.gbl...
As everybody points out, the best way to reduce the memory footprint of a .net application is to minimize it and restore it. This can make my app

go
from 40Mb of usage to about 3Mb of usage. Of course it will grow again
gradually...

My clients have requested that I somehow automate this... so that it
achieves the same result periodically without them having to minimize the application. They claim otherwise it's difficult for them to monitor their users' machines for resource utilization.

Any ideas?

TIA,
John


Nov 16 '05 #3

P: n/a
Actually I have a question about this...
Why *does* the workingset gradually increase in my .net app, is this an
indication of a leak or is it normal for the amount to increase over time?

My understanding (from reading the docs on it) is that this function pages
out the application, does this mean that there will be a performance hit the
next time they try to use the application after I run this function?

Thanks again,
John

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Ob**************@TK2MSFTNGP09.phx.gbl...
John,

You can call the SetProcessWorkingSetSizeEx API function, passing in -1 for the dwMinimumWorkingSetSize and dwMaximumWorkingSetSize parameters to do this.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John Wood" <sp**@isannoying.com> wrote in message
news:eh**************@TK2MSFTNGP12.phx.gbl...
As everybody points out, the best way to reduce the memory footprint of a .net application is to minimize it and restore it. This can make my app

go
from 40Mb of usage to about 3Mb of usage. Of course it will grow again
gradually...

My clients have requested that I somehow automate this... so that it
achieves the same result periodically without them having to minimize the application. They claim otherwise it's difficult for them to monitor their users' machines for resource utilization.

Any ideas?

TIA,
John


Nov 16 '05 #4

P: n/a

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Ob**************@TK2MSFTNGP09.phx.gbl...
John,

You can call the SetProcessWorkingSetSizeEx API function, passing in -1 for the dwMinimumWorkingSetSize and dwMaximumWorkingSetSize parameters to do this.
Ermm... wouldn't that be a massive performance hit? From MSDN:

"If both dwMinimumWorkingSetSize and dwMaximumWorkingSetSize have the
value -1, the function temporarily trims the working set of the specified
process to zero. This essentially swaps the process out of physical RAM
memory."

So you're swapping the process out, and then presumably swapping it back in
as needed. Pretty slow I'd have thought.

What exactly is the problem with memory? Is it simply that it's a "big"
number in task manager, or is there an actual performance issue?

Stu


Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John Wood" <sp**@isannoying.com> wrote in message
news:eh**************@TK2MSFTNGP12.phx.gbl...
As everybody points out, the best way to reduce the memory footprint of a .net application is to minimize it and restore it. This can make my app

go
from 40Mb of usage to about 3Mb of usage. Of course it will grow again
gradually...

My clients have requested that I somehow automate this... so that it
achieves the same result periodically without them having to minimize the application. They claim otherwise it's difficult for them to monitor their users' machines for resource utilization.

Any ideas?

TIA,
John


Nov 16 '05 #5

P: n/a
I use this approach on rather feeble laptop with 256MB - no performance hit
is perceptible. My app memory jumps between 30MB and 0.5MB without any
perceptible disk activity. However this would depend on application itself:
if you modify a lot of data in RAM, then reducing working set could cause
actual swapping. If you have mostly code and not changed data - swapping
will just free memory.

HTH
Alex

"Stu Smith" <st*****@nospam-digita.com> wrote in message
news:uj*************@TK2MSFTNGP10.phx.gbl...

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:Ob**************@TK2MSFTNGP09.phx.gbl...
John,

You can call the SetProcessWorkingSetSizeEx API function, passing in -1
for the dwMinimumWorkingSetSize and dwMaximumWorkingSetSize parameters to do
this.
Ermm... wouldn't that be a massive performance hit? From MSDN:

"If both dwMinimumWorkingSetSize and dwMaximumWorkingSetSize have the
value -1, the function temporarily trims the working set of the specified
process to zero. This essentially swaps the process out of physical RAM
memory."

So you're swapping the process out, and then presumably swapping it back

in as needed. Pretty slow I'd have thought.

What exactly is the problem with memory? Is it simply that it's a "big"
number in task manager, or is there an actual performance issue?

Stu


Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John Wood" <sp**@isannoying.com> wrote in message
news:eh**************@TK2MSFTNGP12.phx.gbl...
As everybody points out, the best way to reduce the memory footprint
of
a .net application is to minimize it and restore it. This can make my
app go
from 40Mb of usage to about 3Mb of usage. Of course it will grow again
gradually...

My clients have requested that I somehow automate this... so that it
achieves the same result periodically without them having to minimize

the application. They claim otherwise it's difficult for them to monitor their users' machines for resource utilization.

Any ideas?

TIA,
John



Nov 16 '05 #6

P: n/a
Yeah I can't imagine it's much different from just minimizing the app and
restoring it... which doesn't add much hit at all.

"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:uI**************@TK2MSFTNGP10.phx.gbl...
I use this approach on rather feeble laptop with 256MB - no performance hit is perceptible. My app memory jumps between 30MB and 0.5MB without any
perceptible disk activity. However this would depend on application itself: if you modify a lot of data in RAM, then reducing working set could cause
actual swapping. If you have mostly code and not changed data - swapping
will just free memory.

HTH
Alex

"Stu Smith" <st*****@nospam-digita.com> wrote in message
news:uj*************@TK2MSFTNGP10.phx.gbl...

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote

in
message news:Ob**************@TK2MSFTNGP09.phx.gbl...
John,

You can call the SetProcessWorkingSetSizeEx API function, passing

in -1
for the dwMinimumWorkingSetSize and dwMaximumWorkingSetSize parameters to
do
this.


Ermm... wouldn't that be a massive performance hit? From MSDN:

"If both dwMinimumWorkingSetSize and dwMaximumWorkingSetSize have the
value -1, the function temporarily trims the working set of the specified process to zero. This essentially swaps the process out of physical RAM
memory."

So you're swapping the process out, and then presumably swapping it back

in
as needed. Pretty slow I'd have thought.

What exactly is the problem with memory? Is it simply that it's a "big"
number in task manager, or is there an actual performance issue?

Stu


Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John Wood" <sp**@isannoying.com> wrote in message
news:eh**************@TK2MSFTNGP12.phx.gbl...
> As everybody points out, the best way to reduce the memory footprint of
a
> .net application is to minimize it and restore it. This can make my

app go
> from 40Mb of usage to about 3Mb of usage. Of course it will grow again > gradually...
>
> My clients have requested that I somehow automate this... so that it
> achieves the same result periodically without them having to

minimize the
> application. They claim otherwise it's difficult for them to monitor

their
> users' machines for resource utilization.
>
> Any ideas?
>
> TIA,
> John
>
>



Nov 16 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.