当前在线人数16190
首页 - 分类讨论区 - 电脑网络 - 窗口里的风景版 - 同主题阅读文章

此篇文章共收到打赏
0

  • 10
  • 20
  • 50
  • 100
您目前伪币余额:0
未名交友
[更多]
[更多]
About memory usage of .Net program
[版面:窗口里的风景][首篇作者:LodossWar] , 2003年10月23日11:54:04 ,188次阅读,0次回复
来APP回复,赚取更多伪币 关注本站公众号:
[分页:1 ]
LodossWar
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 1 ]

发信人: LodossWar (sleepycat), 信区: DotNet
标  题: About memory usage of .Net program
发信站: Unknown Space - 未名空间 (Thu Oct 23 11:55:15 2003) WWW-POST

My words: I have tested what the paper said with my own programs. It is true
that simple WinForms will const you more than 10M. And when you start two
instances of a same program, it will cost double memory, which is 20M.

I know the way to save memory for 2-instances case. Provide your own loader of
IL classes and let those two instances share libraries. This is the way I used
in Java, which will save you lots of memory. But this way sacrifice security
feature of "sandbox". So use this trick carefully.  :)

The article:
http://msdn.microsoft.com/msdnmag/issues/02/09/AdvancedBasics/default.aspx

Q I have a question about the memory footprint in an application built using
the Microsoft® .NET Framework. I built a little sticky notes utility as
part of a learning exercise in a class on coding techniques for Visual
Basic® .NET. It was a simple program that had one small hidden form and a
Notify icon, but it allocated 12MB of memory! That wouldn't matter for a
robust data-driven application, but is there any way to reduce the memory
footprint for a small Visual Basic .NET utility?

A To test your problem, I created a simple Visual Basic .NET Windows®
Forms application that had no event code or controls. I ran the program and
looked in Task Manager at the memory utilization. The memory used ranged from
7,980KB to 8,020KB, with the default settings for the project in Visual
Studio® .NET.
  I recompiled the application in Release mode and checked its memory again.
It then showed 6,328KB, so just changing to Release mode reduced the memory
footprint considerably. The file size of the .exe also dropped, from 8KB to
6KB.
  Next, I added two textboxes and a button control and recompiled and ran the
application. This resulted in an application size of 6,724KB. At this point,
the total memory size of the application was quite small. I decided to create
a similar C# application and check that in order to compare. The C#
application with no controls used 6,200KB, so there was very little difference
between a C# or Visual Basic .NET application, at least at first glance.
  I thought that Windows Forms would add a bit of overhead, so I created a
simple console application that I could run at the command prompt. This
application would simply write "Hello World" and wait for the user to press a
key. No Windows Forms or other sophisticated code was involved. Running this
application compiled with Debug resulted in a 4,312KB footprint. This simple
console application showed a size of 3,748KB when compiled in Release mode.
  So, it appeared that Windows Forms added a good bit of size to the
application. That actually makes sense since adding GUI support to any
application naturally should add some overhead. It's pretty clear that the
Microsoft .NET Framework and Windows Forms architecture was playing a major
role in the memory used by the console application.
  Before doing any more experiments, I thought it would be good to get more
information on memory usage, which became the answer to the next question.






--
※ 修改:·LodossWar 於 Oct 23 11:55:15 修改本文·[FROM: 151.201.]
※ 来源:.Unknown Space - 未名空间 mitbbs.com.[FROM: 151.201.]

 
[分页:1 ]
[快速返回] [ 进入窗口里的风景讨论区] [返回顶部]
回复文章
标题:
内 容:

未名交友
将您的链接放在这儿

友情链接


 

Site Map - Contact Us - Terms and Conditions - Privacy Policy

版权所有,未名空间(mitbbs.com),since 1996