设置最大内存使用C#

编程入门 行业动态 更新时间:2024-10-12 20:22:26
本文介绍了设置最大内存使用C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有必须使用我没有写,我没有改变它的功率库的应用程序。基本上有内存泄漏,所以长它运行,它越泄漏;它基本上只是写道,我没有删除的权力陈旧页面文件。内存泄漏实际上并没有引起程序崩溃,它只是简单地吃了所有的记忆。当使用所有系统的memeory,操作系统将刚开始删除旧的页面文件,一切都正常运行。

I have an application that must use a library that I didn't write and I don't have the power to change it. Basically there is a memory leak, so the long it runs, the more it leaks; it basically just writes stale pagefiles that I don't have the power to delete. The memory leak doesn't actually cause the program to crash, it just simply eats up all the memory. When it is using all the system's memeory, the OS will just start deleting the old page files and everything runs fine.

如果我一个2GB的系统上运行我的应用程序,它会使用2 GB和继续运行;同为16GB的系统。

If I run my app on a 2gb system, it will use 2 gb and continue to run; same for a 16gb system.

有没有办法来设置内存的应用程序可以使用的金额是多少?

Is there a way to set the amount of memory an application can use?

推荐答案

这是一个每个进程限制在Windows中。每个过程在一个32位机得到〜2GB虚拟地址空间(这就是堆利用的)。恐怕没有什么可以做这件事。

That is a per-process limitation in Windows. Each process gets ~2GB virtual address space (that is what Heap makes use of) in a 32-bit machine. And I am afraid there is not much you can do about it.

粗略地说,CLR能够保持高达内存中的对象〜1.6GB。这应该是足以满足大多数的应用程序。如果没有,那么你需要在你的应用程序。

Roughly, CLR is able hold upto ~1.6GB of objects in memory. That should be enough for most of the applications. If not, then you need to work on your application.

在我的情况,我遇到了类似的问题,然后使用SqlDataReader的获取在指定的块大小的物体,过程它,计算它,从内存中清除它,然后再取另一块

In my case, I faced a similar problem and then used SqlDataReader to fetch objects in a specified chunk size, process it, compute it, clean it from memory, and then fetch another chunk.

还有MSDN上详细的文章 - 调查内存问题

There is also a detailed article on MSDN - Investigating Memory Issues

希望这将是有益的。

更多推荐

设置最大内存使用C#

本文发布于:2023-05-29 03:38:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/335889.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:内存

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!