使用虚拟内存创建一个大数组 [英] creating a big array using virtual memory

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

问题描述

我希望添加一个新的数据类型来帮助我进行数学计算。我们都知道系统内存有限,即我们无法创建一个非常大的数组。例如[100000000 ....]。新数据类型将部分使用RAM和部分文件。例如,如果我声明一个大小为100000000的数组


#include" stdio.h"


int a [10000] [10000] = {1,2,3,4};


int main( )

{

返回0;

}


因此内存有限制分配更大的尺寸。所以新的数据类型应该能够处理大的值(64位的值)并支持大量的内存位置。


提示:我们都有虚拟内存的想法。页面部分在RAM中,部分在HARDDISK上。它类似于这个问题。数组的部分位于ram中,部分位于文件中。我们可以使用来自RAM的10000字节空间来存储值。对变量的每次访问都有两种可能性。它可以在RAM或文件中。

I wish to add a new datatype to help me in doing mathametical computations.We all know that the system has got limited amount of memory ie we cannot create an array of very big size. for example a[100000000....]. The new data type will partially use RAM and partially file.For example if i declare an array of size 100000000
Try to compile this program

#include"stdio.h"

int a[10000][10000] = {1,2,3,4};

int main()
{
return 0;
}

So there is a limit to the memory allocation for bigger size. So the new datatype should be able to handle big values (value of 64 bits) and support large number of memory locations.

Hint : We all have the idea of virtual memory.The pages are partially in RAM and partially on HARDDISK. It is similar to this problem. The part of array is in ram and part on a file. We can use space of 10000 bytes from RAM to store the values.Every access to the variable can have two possiblity. It can be in RAM or in file.

推荐答案

那个(humongous)数组稀疏还是密集?如果它是密集的,所有的赌注都是关闭的,即它是为你的进程分配内存的操作系统,它不能分配超过

最大值。或者你需要一台更大的电脑。


如果阵列稀疏,可以考虑很多其他选择。


亲切问候,


Jos
Is that (humongous) array sparse or dense? If it''s dense all bets are off, i.e. it''s
the OS that allocated memory to your process and it can''t allocate more than
its maximum. Or you need a bigger computer.

If the array is sparse there are lots of alternatives to think about.

kind regards,

Jos



尝试编译此程序
Try to compile this program



我做了。它有效。


最大数组大小为0x7fffffff(2,147,483,647),大于100000000。

I did. It worked.

Max array size is 0x7fffffff (2,147,483,647) which is larger than 100000000.



我做到了。它工作。


最大数组大小为0x7fffffff(2,147,483,647),大于100000000.
I did. It worked.

Max array size is 0x7fffffff (2,147,483,647) which is larger than 100000000.



我认为域名10,000x10,000整数数组的适用性非常小。

也许OP应该详细说明那些''数学计算''

的全部内容。


亲切的问候,


Jos

I think the domain of applicability for an array of 10,000x10,000 ints is very small.
Maybe the OP should elaborate a bit on what those ''mathematical computations''
are all about.

kind regards,

Jos


这篇关于使用虚拟内存创建一个大数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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