.NET像猪一样吃着记忆 [英] .NET eats memory like a pig

查看:55
本文介绍了.NET像猪一样吃着记忆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道关于引用计数的一切,并确保你没有

大型物体。我还用多种工具描述了我的应用程序。

我知道GC收集内存的事实,但没有必要将它回馈给操作系统。
操作系统。


似乎.NET win应用程序只会在操作系统需要时将内存返回给操作系统。
要求它。但!!!当操作系统要求它通常为时已晚,吨交换和性能缓慢。


我只是没有得到它,怎么能.NET是一项卓越的技术,吃得太多了吗?
RAM?我看到有些人强迫他们的应用程序最小化或削减他们的工作空间只是为了释放内存 - 这是一个坏主意。其他人卸载

a应用程序域以节省内存...好一点但仍然很多

只是为了获得一些内存回到操作系统。


有些人告诉我这是为运行时付出的代价。对不起,我已经使用了

其他运行时用于Windows应用程序而且它们没有吃太多内存。

对于上帝的爱,AcuCobol运行时不需要那么多RAM(不是我现在想要在COBOL中编码



最后,它似乎就像在操作系统中运行操作系统一样。我很沮丧

一个愚蠢的Windows应用程序可以花20M什么都不做,如果你的b $ b有一个应用程序可以做更多的东西,它可能需要40M而你必须

担心每个Dispose和参考,所以它不会跳到100M。


我并不孤单这个问题....

http://www.dotnet247.com/247referenc.../14/73033.aspx



I know everything about reference counting and making sure you don''t have
large objects lying around. I have also profiled my app with multiple tools.
I know about the fact GC collects memory but not necessary give it back to
the OS.

It seems that .NET win app will only return memory to the OS when the OS is
asking for it. But!!! When the OS is asking for it is usually too late, tons
of swapping and slow performance.

I just don''t get it, how can .NET a superior technology is eating so much
RAM? I see that some people force their app to minimize or trim their
workspace just to free the memory - that is a bad idea. Other people unload
a application domain to save memory... a little better but still lots of
work just to get some memory back to the OS.

Some people tell me it is the price to pay for a runtime. Sorry, I have used
other runtimes for windows applications and they don''t eat so much memory.
For the love of god, AcuCobol runtime does not take so much RAM (not that I
want to code in COBOL now)

At the end, it seems it is like running an OS within an OS. I am frustrated
that a stupid windows application can take 20M for doing nothing, and if you
have an app that does a little more stuff, it can take 40M and you have to
worry about each Dispose and reference so it will not jump to 100M.

and I am not alone with this problem....

http://www.dotnet247.com/247referenc.../14/73033.aspx



推荐答案

好吧,从你的评论中可能听起来你可能还不完全理解在.NET中如何管理内存。 .NET不使用像COM

应用程序这样的引用计数器。


最终,它不是占用内存的框架,它是你的

申请。在任何编程环境中,如果你编写邋code的代码,你就会得到糟糕的表现。我首先检查你的代码,并确保你在调用任何使用非托管资源的对象上调用,调用Close on

任何打开的对象,管理您可能正在使用的任何多线程

a监视眼睛,使用Marshall.ReleaseComObject类允许

框架释放对任何和所有COM对象的引用使用,在ASP.NET页面等中使用COM

对象时,将ASP.NET页面的ASPCompat属性设置为True
b
/>
简而言之,在你击败平台之前,检查你在那个平台上做什么。你还没有告诉我们你的代码是什么?b $ b试图运行。如果你这样做,我们可以了解我们如何能够帮助你或者向你指明正确的学习方向。

" Mike P" < M _ ****** @ hotmail.com>在消息中写道

news:29 ******************** @ news20.bellglobal.com。 ..
Well, from your comments it sounds like you might not fully understand how
memory is managed in .NET. .NET does NOT use reference counters like COM
applications do.

Ultimately, it''s not the Framework that is tying up memory, it is your
application. In any programming environment, if you write sloppy code, you
get poor performance. I''d start by examine your code and make sure you are
calling Dispose on any object that uses unmanaged resources, call Close on
any object that is opened, manage any multi-threading you may be doing with
a watchful eye, use the Marshall.ReleaseComObject class to allow the
Framework to release its references to any and ALL COM objects you may be
using, set the ASPCompat property of ASP.NET pages to True when using COM
objects in ASP.NET pages, etc. etc.

In short, before you beat up on the platform, examine what you are doing in
that platform. You haven''t told us anything about the code you are
attempting to run. If you do, we can get a feel for how we may be able to
help or point you in the right learning direction.
"Mike P" <m_******@hotmail.com> wrote in message
news:29********************@news20.bellglobal.com. ..
我知道关于引用计数的一切,并确保你没有大型物体。我还用多种
工具描述了我的应用程序。
我知道GC收集内存的事实,但没有必要将它还给操作系统。

似乎当操作系统
要求时,.NET win应用程序只会将内存返回给操作系统。但!!!操作系统要求它通常为时已晚,交换量大,性能慢。

我只是不明白,.NET如何优越技术吃得那么多内存?我看到有些人强迫他们的应用程序最小化或修剪他们的工作空间只是为了释放内存 - 这是一个坏主意。其他人
卸载一个应用程序域来节省内存...好一点但仍有很多工作只是为了让一些内存回到操作系统。

有些人告诉我这是为运行时付出的代价。对不起,我已经使用
其他运行时用于Windows应用程序而且他们没有吃太多内存。
对于上帝的爱,AcuCobol运行时不占用太多内存(不是那样的)
我现在想要在COBOL中编码。

最后,它似乎就像在操作系统中运行操作系统一样。我很沮丧
一个愚蠢的Windows应用程序可以花20M什么都不做,如果你有一个应用程序做更多的东西,它可能需要40M而你我不得不担心每个处理和参考,所以它不会跳到100M。

我并不孤单这个问题......

http://www.dotnet247.com/247referenc.../14/73033.aspx


I know everything about reference counting and making sure you don''t have
large objects lying around. I have also profiled my app with multiple
tools.
I know about the fact GC collects memory but not necessary give it back to
the OS.

It seems that .NET win app will only return memory to the OS when the OS
is
asking for it. But!!! When the OS is asking for it is usually too late,
tons
of swapping and slow performance.

I just don''t get it, how can .NET a superior technology is eating so much
RAM? I see that some people force their app to minimize or trim their
workspace just to free the memory - that is a bad idea. Other people
unload
a application domain to save memory... a little better but still lots of
work just to get some memory back to the OS.

Some people tell me it is the price to pay for a runtime. Sorry, I have
used
other runtimes for windows applications and they don''t eat so much memory.
For the love of god, AcuCobol runtime does not take so much RAM (not that
I
want to code in COBOL now)

At the end, it seems it is like running an OS within an OS. I am
frustrated
that a stupid windows application can take 20M for doing nothing, and if
you
have an app that does a little more stuff, it can take 40M and you have to
worry about each Dispose and reference so it will not jump to 100M.

and I am not alone with this problem....

http://www.dotnet247.com/247referenc.../14/73033.aspx




好吧,从你的评论中听起来你可能不完全理解在.NET中如何管理内存。 .NET不使用像COM

应用程序这样的引用计数器。


最终,它不是占用内存的框架,它是你的

申请。在任何编程环境中,如果你编写邋code的代码,你就会得到糟糕的表现。我首先检查你的代码,并确保你在调用任何使用非托管资源的对象上调用,调用Close on

任何打开的对象,管理您可能正在使用的任何多线程

a监视眼睛,使用Marshall.ReleaseComObject类允许

框架释放对任何和所有COM对象的引用使用,在ASP.NET页面等中使用COM

对象时,将ASP.NET页面的ASPCompat属性设置为True
b
/>
简而言之,在你击败平台之前,检查你在那个平台上做什么。你还没有告诉我们你的代码是什么?b $ b试图运行。如果你这样做,我们可以了解我们如何能够帮助你或者向你指明正确的学习方向。

" Mike P" < M _ ****** @ hotmail.com>在消息中写道

news:29 ******************** @ news20.bellglobal.com。 ..
Well, from your comments it sounds like you might not fully understand how
memory is managed in .NET. .NET does NOT use reference counters like COM
applications do.

Ultimately, it''s not the Framework that is tying up memory, it is your
application. In any programming environment, if you write sloppy code, you
get poor performance. I''d start by examine your code and make sure you are
calling Dispose on any object that uses unmanaged resources, call Close on
any object that is opened, manage any multi-threading you may be doing with
a watchful eye, use the Marshall.ReleaseComObject class to allow the
Framework to release its references to any and ALL COM objects you may be
using, set the ASPCompat property of ASP.NET pages to True when using COM
objects in ASP.NET pages, etc. etc.

In short, before you beat up on the platform, examine what you are doing in
that platform. You haven''t told us anything about the code you are
attempting to run. If you do, we can get a feel for how we may be able to
help or point you in the right learning direction.
"Mike P" <m_******@hotmail.com> wrote in message
news:29********************@news20.bellglobal.com. ..
我知道关于引用计数的一切,并确保你没有大型物体。我还用多种
工具描述了我的应用程序。
我知道GC收集内存的事实,但没有必要将它还给操作系统。

似乎当操作系统
要求时,.NET win应用程序只会将内存返回给操作系统。但!!!操作系统要求它通常为时已晚,交换量大,性能慢。

我只是不明白,.NET如何优越技术吃得那么多内存?我看到有些人强迫他们的应用程序最小化或修剪他们的工作空间只是为了释放内存 - 这是一个坏主意。其他人
卸载一个应用程序域来节省内存...好一点但仍有很多工作只是为了让一些内存回到操作系统。

有些人告诉我这是为运行时付出的代价。对不起,我已经使用
其他运行时用于Windows应用程序而且他们没有吃太多内存。
对于上帝的爱,AcuCobol运行时不占用太多内存(不是那样的)
我现在想要在COBOL中编码。

最后,它似乎就像在操作系统中运行操作系统一样。我很沮丧
一个愚蠢的Windows应用程序可以花20M什么都不做,如果你有一个应用程序做更多的东西,它可能需要40M而你我不得不担心每个处理和参考,所以它不会跳到100M。

我并不孤单这个问题......

http://www.dotnet247.com/247referenc.../14/73033.aspx


I know everything about reference counting and making sure you don''t have
large objects lying around. I have also profiled my app with multiple
tools.
I know about the fact GC collects memory but not necessary give it back to
the OS.

It seems that .NET win app will only return memory to the OS when the OS
is
asking for it. But!!! When the OS is asking for it is usually too late,
tons
of swapping and slow performance.

I just don''t get it, how can .NET a superior technology is eating so much
RAM? I see that some people force their app to minimize or trim their
workspace just to free the memory - that is a bad idea. Other people
unload
a application domain to save memory... a little better but still lots of
work just to get some memory back to the OS.

Some people tell me it is the price to pay for a runtime. Sorry, I have
used
other runtimes for windows applications and they don''t eat so much memory.
For the love of god, AcuCobol runtime does not take so much RAM (not that
I
want to code in COBOL now)

At the end, it seems it is like running an OS within an OS. I am
frustrated
that a stupid windows application can take 20M for doing nothing, and if
you
have an app that does a little more stuff, it can take 40M and you have to
worry about each Dispose and reference so it will not jump to 100M.

and I am not alone with this problem....

http://www.dotnet247.com/247referenc.../14/73033.aspx




Mike,


Net不是为Commodore 64设计的。即使是现有的PDA也有更多

内存比那些。


不要试图将用于计算机的方法作为Commodore 64用于这个

世纪。


我已为计算机编程,我必须赢得一个字节才能得到我想要的b $ b,我很幸运,这不是必需的再过一段时间了,在这个世纪,

所有发布未使用内存的内容都将使用托管代码来完成

实例与Net。


我找到的方法是你只需要处理时间,如果需要最好的

一个。


要给一个美甲,我知道那些正在进行碎片整理的人有磁盘每个

小时。如果你也这样做,那么可能不是最有成效的

一个。


只是我的意见。


Cor
Mike,

Net is not designed for a Commodore 64. Even the current PDA''s have more
memory than those.

Don''t try to put methods used for computers as the Commodore 64 in this
century.

I have programmed for computers where I had to win a single byte to get what
I wanted, I am lucky that is not necessary anymore and in this century
everything to release unused memory will be done using the managed code by
instance with Net.

I find the method that you only use processing time if it is needed the best
one.

To give a methaphor, I know people who are defragmentating there disk every
hour. If you do that as well, fine however probably not the most productive
one.

Just my opinion.

Cor


这篇关于.NET像猪一样吃着记忆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆