Home All Groups Group Topic Archive Search About

Memory Usange In VB.NET

Author
16 Aug 2006 8:16 AM
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.

Author
16 Aug 2006 9:31 AM
Michel Posseth [MCP]
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]




Show quoteHide quote
"Cylix" wrote:

> 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.
>
>
Author
17 Aug 2006 3:10 AM
Cylix
But I just use that line once and never use it any more.
So I don't want it to keep any cache ...
Author
17 Aug 2006 6:39 AM
Michel Posseth [MCP]
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]


Show quoteHide quote
"Cylix" wrote:

> But I just use that line once and never use it any more.
> So I don't want it to keep any cache ...
>
>
Author
17 Aug 2006 8:02 AM
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.
Author
13 Oct 2006 11:08 AM
Jovo Mirkovic
It's working... but it only increase Memory, Virtual Memory is still
growing..:(

*** Sent via Developersdex http://www.developersdex.com ***