内存大小? [英] Memory size?

查看:79
本文介绍了内存大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨大家好,


如何确定总主内存大小和免费大小

内存可用字节数?


我试图使用malloc.h中的mallinfo() - 在Windows中产生一些奇怪的值

(cygwin,gcc 3.3.1),在Linux中总是0(2.4。 22,gcc

3.3.2)。


提前致谢,

J?rg

解决方案

Joerg Schwerdtfeger写道:

如何确定总主内存大小和空闲大小
内存以字节为单位?

我试图使用malloc.h中的mallinfo() - 在Windows中产生了一些奇怪的值(cygwin,gcc 3.3.1),并且始终为0 Linux(2.4.22,gcc
3.3.2)。




使用适用于您的操作系统的API。两个操作系统然后是两个不同的解决方案。


在分页机上一定要找出免费内存*的含义*


< blockquote>在< c9 ************* @ news.t-online.com> Joerg Schwerdtfeger < SC ******* @ gmx.de>写道:

我如何确定总的主内存大小和可用的内存大小(以字节为单位)?


您需要这些信息吗?你是否意识到关于可用内存的信息是非常不稳定的,当你有机会使用它时,它可能已经不正确了?

我试图使用malloc.h中的mallinfo() - 在Windows中产生一些奇怪的值(cygwin,gcc 3.3.1),在Linux中总是0(2.4.22,gcc
3.3.2)。




标准C库中没有这样的功能,所以无论你得到什么结果

都是正确的(你的程序通过

调用一个既不是由它定义也不是标准的一部分的函数来调用未定义的行为。


Dan

-

Dan Pop

DESY Zeuthen,RZ集团

电子邮件: Da ***** @ ifh.de


2004年5月27日星期四15 :34:17 + 0200,在comp.lang.c中,Joerg Schwerdtfeger

< sc ******* @ gmx.de>写道:

嗨大家好,
如何确定总的主内存大小和可用的内存大小?字节数<? / blockquote>


没有标准的方法可以做到这一点。您的操作系统可能不允许您使用。

在多用户虚拟内存中,它甚至可能不是一个有意义的问题。

系统。


在专门针对您的编译器和/或操作系统的小组中提问。

-

Mark McIntyre

CLC FAQ< http ://www.eskimo.com/~scs/C-faq/top.html>

CLC自述文件:< http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html> ;

---- ==通过Newsfeed.Com发布 - 无限制 - 未经审查 - 安全Usenet新闻== ----
http://www.newsfeed.com 世界排名第一的新闻组服务! > 100,000新闻组

--- = 19东/西海岸专业服务器 - 通过加密的总隐私= ---

---- ==通过新闻发布.Com - Unlimited-Uncensored-Secure Usenet News == ----
http:// www.newsfeed.com 世界排名第一的新闻组服务! > 100,000新闻组

--- = 19东/西海岸专业服务器 - 通过加密的总隐私= ---


Hi folks,

how can I determine the total main-memory size and the size of free
memory available in bytes?

I tried to use mallinfo() from malloc.h - resulting some strange values
in Windows (cygwin, gcc 3.3.1) and always 0 in Linux (2.4.22, gcc
3.3.2).

Thanks in advance,
J?rg

解决方案

Joerg Schwerdtfeger writes:

how can I determine the total main-memory size and the size of free
memory available in bytes?

I tried to use mallinfo() from malloc.h - resulting some strange values
in Windows (cygwin, gcc 3.3.1) and always 0 in Linux (2.4.22, gcc
3.3.2).



Use the API for your OS. Two OSes then two different solutions.

Be sure to find out what free memory *means* too, on a paging machine.


In <c9*************@news.t-online.com> "Joerg Schwerdtfeger" <sc*******@gmx.de> writes:

how can I determine the total main-memory size and the size of free
memory available in bytes?
What do you need this information for? Do you realise that the
information about the free memory is extremely volatile and, by the time
you get a chance to use it, it may already be incorrect?
I tried to use mallinfo() from malloc.h - resulting some strange values
in Windows (cygwin, gcc 3.3.1) and always 0 in Linux (2.4.22, gcc
3.3.2).



No such function in the standard C library, so whatever results you got
were the correct ones (your program invoked undefined behaviour by
calling a function that was neither defined by it nor part of the standard
C library).

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de


On Thu, 27 May 2004 15:34:17 +0200, in comp.lang.c , "Joerg Schwerdtfeger"
<sc*******@gmx.de> wrote:

Hi folks,

how can I determine the total main-memory size and the size of free
memory available in bytes?



there''s no standard way to do that. You may not be permitted to by your OS.
It might not even be a meaningful question, in a multiuser virtual memory
system.

Ask in a group dedicated to your compiler and/or OS.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---


这篇关于内存大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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