Memory Usange In VB.NET

C

Cylix

When I run this centence, The memory raise 4Mb in memory:
If Process.GetProcessesByName("ABC,EXE").Length > 1 Then

And the routine is end, the memory doesn't drop,
Actually, How Can I free up my memory in a VB.NET application?

GC.collect() seems not so work.
 
G

Guest

My counter question to you is Why ?


As the architecture of a .Net app is to reserve memory

I.O.W.

A .Net Program reserves memory during execution it doesn`t mean that it is
actually using this memory space . advantage of this aproach is a higher
execution speed as memory does not have to be claimed and released on every
memory intensive call .

read this for detailed info :

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/dotnetperftechs.asp


if you really need to free up the memory , thus solving this "cosmetic"
problem

you can do this :

Private Declare Function SetProcessWorkingSetSize Lib "kernel32.dll" ( _
ByVal process As IntPtr, _
ByVal minimumWorkingSetSize As Integer, _
ByVal maximumWorkingSetSize As Integer) As Integer

GC.Collect()
GC.WaitForPendingFinalizers()
SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1)


regards

Michel Posseth [MCP]
 
C

Cylix

But I just use that line once and never use it any more.
So I don't want it to keep any cache ...
 
G

Guest

No it isn`t about caching values

The framework determines the potential memory usage of your program and
reserves the memory ,

If you don`t use it fine ,,, but if you might use it this would speed op the
overall perfomance of your application .


if the system is running low on memory the GC could kick in and give the
memory back to the system ,,, however with modern computers this is not
lickely to happen so often .

as i said i once had a customer who demanded a low mem usage in the
taskmanager so i used the trick i showed in my previous post ,,, however this
is more cosmetic as a reall usage strategy as it hurts the performance of
your application .


regards

Michel Posseth [MCP]
 
C

Cylix

Dear Michel,

I would like to know more about this.
I have already tried your code and it really make the memory shown on
task manager.
May I know what memory is release under your code?

And how it hunrt the application performance?

Actually, In my office, most of computer is P4 2GHz with 512MB Ram,
but some of old machines are just P3 800MHz, 256MB Ram,
They need to open a number of MS Word and MS OUTLOOK Items.

So, The memory is really limited.
 
J

Jovo Mirkovic

It's working... but it only increase Memory, Virtual Memory is still
growing..:(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top