Memory management problem

G

Guest

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim a As ArrayList, i As Long
a = New ArrayList
For i = 1 To 1000000
a.Add(10)
Next
End If
End Sub

This code causes the process aspnet_wp.exe to grow form 2MB to 45MB in size.
After page is processed the size does not comes down. I have tried
a.clear()
me.dispose()

whether i put 'a' in session or not, the process grows. I want to manage
this uncontrolled situation. pls help.
samik
 
H

Hans Kesting

samik said:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim a As ArrayList, i As Long
a = New ArrayList
For i = 1 To 1000000
a.Add(10)
Next
End If
End Sub

This code causes the process aspnet_wp.exe to grow form 2MB to 45MB
in size. After page is processed the size does not comes down. I have
tried a.clear()
me.dispose()

whether i put 'a' in session or not, the process grows. I want to
manage this uncontrolled situation. pls help.
samik

The fact that memorysize increases probably doesn't surprise you
(as you are adding a million values to that arraylist). The fact that it
doesn't immediatly decrease probably does surprise you, but is
is correct!

Try loading this page a couple of times and see the memory consumption.
It probably will go up again at first, but after a couple of times that memory
consumption will stop or it will go down. It may also go down after
you wait a while.

This is garbage collection at work. Memory that your application doesn't use
anymore is not immediately returned to the operation system, only when
the garbage collector comes around to it. This might happen when the
application is idle or when available memory is too low.

Hans Kesting
 
G

Guest

thanks for ur reply.
actually we have a problem that the process size becomes ever growing when a
bigger load is there. and after growing upto 450-500 MB the process hang. So
we have to have a mechanism through which we can release this unused memory
asap. can u suggest something...
 
G

Guest

thanks for ur reply.
actually when the load inceases. this process size becomes virtually ever
growing. it comes down only in a few bytes and increases in MB. after going
upto 450-500MB the process hangs. So we need to control this size. Can u
suggest something?
 
G

Guest

Samik,

That is the answer I am eager to know to. From the MSDN reference, looks
like there is still not a good way to quickly remove the memory usage. So
did you ever find a useful solution?

Thanks in advance,
Agnes
 
M

Martin Dechev

Hi,

Did you try to explicitly call GC.Collect()?

Hope this helps,
Martin Dechev
ASP.NET MVP
 

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