Memory Consumption

G

Guest

HI, there,

I am developing the desktop application using VB 6 as well as VB.Net.

I have noticed one significant difference.

A created an empty windows app in VB contsing of a single form and there is
no coding and any control on it.

When I executed the EXE, it consumed 983KB of memory.

I created the same type of EXE in VB.net and when I executed I was
astonished to see that it Consumed approx 15 MB of Memory.

I looked very strange to me as from the primary analysis I think it might me
that CLR launched all the necessary DLL's in the memory space of the EXE that
i created like, System.Windows.dll, System.dll etc.

But I just want to know if this is the case then .NET windows applications
are very memory consuming as compared to their VB counterparts.

Could any one please eloberate this issue to me?
 
G

Guest

You are correct in your assumption as to the memory consumption. Your app has
loaded the CLR and the FCL dlls for the System, System.Windows.Forms
namespaces and all the others encountered so far.
The benefit of .NET is not reduced memory footprint. There is a cost to a
managed environment, but if you coded all the capability of .NET in VB and
ran that app, the memory footprint would be enormous. You may not have put
controls on your form, but when you did you would be able to use the to put
together client server applications accessing distant databases, remoting
server objects and calling web services, and doing all other kinds of things
that would take you years to code yourself in VB.

Thats the benefit.
 
N

n!

I would suggest the biggest reason for the memory footprint isn't the CLR or
other DLL's loaded. but rather due to how memory is managed by the CLR and
the garbage collector.

The garbage collector has a behaviour that requires a block of memory to be
allocated (well, technically, a couple of memory blocks) and these memory
blocks will expand depending on the behaviour of your application and how
much garbage is collected. The memory footprint of the application (as
viewed in the task manager, at least) will be larger than an unmanaged
application because of these memory pools allocated by the CLR for providing
memory to the application.

Whilst your application may not be allocating that much memory, to ensure
the memory blocks are not reallocated too frequently to adversely affect an
applications performance it is necessary for a memory block of a certain
size to be allocated.

n!
 
B

Bob Powell [MVP]

The memory manager will initially attempt to grab a of of space for
itself. Just close your eyes, don't worry about it and trust that the
CLR will manage the memory for you.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 

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