如何在Win应用程序中限制虚拟内存的使用? [英] How to limit use of virtual memory in my Win application?

查看:74
本文介绍了如何在Win应用程序中限制虚拟内存的使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何限制PC虚拟内存的使用?我正在运行一个过程

,基本上需要一个txt文件并将其加载到数据表中。问题是

该文件长度超过400,000行(77 MB),过了一段时间我得到了

Windows消息,说明虚拟内存正在变得越来越好低。另外

机器变得非常迟缓(多线程)。有可能

使用虚拟内存直到达到一定限度然后使用HDD

空间?


谢谢。

How can I limit the use of the PC''s virtual memory? I''m running a process
that basically takes a txt file and loads it to a datatable. The problem is
that the file is over 400,000 lines long (77 MB) and after a while I get the
Windows message saying that the virtual memory''s getting really low. Plus
the machine gets really sluggish (with multi-threading). Is it possible to
use the virtual memory until it reaches a certain limit and then use HDD
space?

Thanks.

推荐答案

据我所知,没有办法在

应用程序中操作Windows VM。 VM由操作系统处理,它决定

存储在那里的内容。如果您的应用程序遇到问题

需要大量内存,您可能需要修改应用程序的最低

要求以包含更多内存或尝试阅读文件在

块中,而不是循环遍历所有400,000多行。一个有趣的事情

要注意的是你如何访问该文件。您使用哪个流类来访问该文件?


Kyril


" VM" < VO ****** @ yahoo.com>在消息中写道

新闻:eF ************* @ TK2MSFTNGP11.phx.gbl ...
As far as I know, there is no way to manipulate Windows VM from within an
application. The VM is handled by the operating system and it decides on
what is stored there. If you are encountering problems with your application
taking large amounts of RAM, you may want to modify your minimum
requirements for your app to include more RAM or try to read the file in
chunks rather than looping through all 400,000+ lines. One interesting thing
to note is how you are accessing the file. Which of the stream classes are
you using to access the file?

Kyril

"VM" <vo******@yahoo.com> wrote in message
news:eF*************@TK2MSFTNGP11.phx.gbl...
我如何限制使用PC的虚拟内存?我正在运行一个基本上采用txt文件并将其加载到数据表的进程。问题
是文件超过400,000行(77 MB),过了一段时间我得到了
Windows消息,说虚拟内存真的变得越来越好低。另外
机器变得非常迟缓(多线程)。是否有可能在达到一定限度之前使用虚拟内存然后使用HDD空间?

谢谢。
How can I limit the use of the PC''s virtual memory? I''m running a process
that basically takes a txt file and loads it to a datatable. The problem
is
that the file is over 400,000 lines long (77 MB) and after a while I get
the
Windows message saying that the virtual memory''s getting really low. Plus
the machine gets really sluggish (with multi-threading). Is it possible to
use the virtual memory until it reaches a certain limit and then use HDD
space?

Thanks.



感谢您的回复。我正在使用StreamReader类。


这就是我目前正在做的事情:

private DataTable LoadFile(string sfileName)

{

DataTable DT_Audit = new DataTable(" AZMViewTable");

StreamReader sr = new StreamReader(sFileName);

sAuditRecord = sr.ReadLine();


while(sAuditRecord!= null)

{

rowAudit = DT_Audit.NewRow() ;

//拆分字符串sAuditRecord并将其存储在行中的相应字段中

DT_Audit.Rows.Add(rowAudit);

sAuditRecord = sr .ReadLine();

}

sr.Close();

返回DT_Audit;

}


" Kyril Magnos" < KY ********** @ yahoo.com>在留言中写道

news:uj ************** @ TK2MSFTNGP10.phx.gbl ...
Thanks for your reply. I''m using the StreamReader class.

This is how I am currently doing it:
private DataTable LoadFile(string sfileName)
{
DataTable DT_Audit = new DataTable("AZMViewTable");
StreamReader sr = new StreamReader(sFileName);
sAuditRecord = sr.ReadLine();

while (sAuditRecord != null)
{
rowAudit = DT_Audit.NewRow();
//Split string sAuditRecord and store it in appropriate fields in row
DT_Audit.Rows.Add (rowAudit);
sAuditRecord = sr.ReadLine();
}
sr.Close();
return DT_Audit;
}

"Kyril Magnos" <ky**********@yahoo.com> wrote in message
news:uj**************@TK2MSFTNGP10.phx.gbl...
据我所知,无法在
应用程序中操作Windows VM。 VM由操作系统处理,它决定存储在那里的内容。如果您的
应用程序遇到大量RAM的问题,您可能希望修改您的应用程序的最低要求,以包含更多RAM或尝试以
块的形式读取文件而不是遍历所有400,000多行。一个有趣的
注意事项是你如何访问该文件。您使用哪个流类来访问该文件?

Kyril

VM < VO ****** @ yahoo.com>在消息中写道
新闻:eF ************* @ TK2MSFTNGP11.phx.gbl ...
As far as I know, there is no way to manipulate Windows VM from within an
application. The VM is handled by the operating system and it decides on
what is stored there. If you are encountering problems with your application taking large amounts of RAM, you may want to modify your minimum
requirements for your app to include more RAM or try to read the file in
chunks rather than looping through all 400,000+ lines. One interesting thing to note is how you are accessing the file. Which of the stream classes are
you using to access the file?

Kyril

"VM" <vo******@yahoo.com> wrote in message
news:eF*************@TK2MSFTNGP11.phx.gbl...
我如何限制使用PC'的虚拟记忆?我正在运行
进程,它基本上采用txt文件并将其加载到数据表中。问题
是文件超过400,000行(77 MB),过了一段时间我得到了
Windows消息,说虚拟内存真的变得越来越好低。
加上机器变得非常迟缓(多线程)。是否有可能
使用虚拟内存直到达到一定限度然后使用HDD
空间?

谢谢。
How can I limit the use of the PC''s virtual memory? I''m running a process that basically takes a txt file and loads it to a datatable. The problem
is
that the file is over 400,000 lines long (77 MB) and after a while I get
the
Windows message saying that the virtual memory''s getting really low. Plus the machine gets really sluggish (with multi-threading). Is it possible to use the virtual memory until it reaches a certain limit and then use HDD
space?

Thanks.




另请注意,虚拟内存等于物理内存加硬盘

分配给交换的空间。让你的用户可以选择
为页面文件分配更多的内存。


但是,我认为之前的海报有重组的评论您的代码在

中为了更好地利用可用资源代表更好的解决方案。


Eric
Note, too, that virtual memory equals your physical memory plus hard disk
space allocated to swapping. It may be an option to have your users
allocate more memory to the page file.

However, I think the previous poster''s comments to restructure your code in
order to make better use of available resources represent a better solution.

Eric
As据我所知,没有办法在
应用程序中操作Windows VM。 VM由操作系统处理,它决定
As far as I know, there is no way to manipulate Windows VM from within an
application. The VM is handled by the operating system and it decides on






这篇关于如何在Win应用程序中限制虚拟内存的使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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