Redian新闻
>
a question about virtual memory
avatar
a question about virtual memory# Programming - 葵花宝典
r*e
1
Have been wondering about this for a long time:
In Linux/Unix, how would a process decide the scope of it's virtual memory spa
ce? generally, shouldn't it be as large as the address-space allows?
using swap, why should there be "out of memory" error?
bow .......
avatar
a*a
2
It is due to the allocation algorithm and the allocation pattern of your
program. In some algorithms, memories are organized in pages where one
page is the allocation unit for one request. Therefore, even a single
byte could consume 4k bytes in some program. In this way, the memory
could be exhausted very quick.

【在 r*******e 的大作中提到】
: Have been wondering about this for a long time:
: In Linux/Unix, how would a process decide the scope of it's virtual memory spa
: ce? generally, shouldn't it be as large as the address-space allows?
: using swap, why should there be "out of memory" error?
: bow .......

avatar
r*e
3

Thanks, this answers some questions
But I am still not clear how a program decides how much heap space does it nee
d, or the size of the whole virtual memory space that it will be running in...
. therotically, it could be much larger that the physical memory space if only
the address bits allow, then why should we get "out of memory" error so often
?
thanks,

【在 a**a 的大作中提到】
: It is due to the allocation algorithm and the allocation pattern of your
: program. In some algorithms, memories are organized in pages where one
: page is the allocation unit for one request. Therefore, even a single
: byte could consume 4k bytes in some program. In this way, the memory
: could be exhausted very quick.

avatar
a*a
4
Well, a program does not claim all virtual addresses as its heap space.
Generally each program has a map of virtual addresses to valid memory space
claimed by the program. Therefore, OS will manage these maps.
Before a program could access some memory place, it must claim it, which
is done by some system call(s). Ideally the OS would try to meet requests until
all available virtual space exhausted. But due to some physical or design
limits, the OS might throw "out of memory" error by some imp

【在 r*******e 的大作中提到】
:
: Thanks, this answers some questions
: But I am still not clear how a program decides how much heap space does it nee
: d, or the size of the whole virtual memory space that it will be running in...
: . therotically, it could be much larger that the physical memory space if only
: the address bits allow, then why should we get "out of memory" error so often
: ?
: thanks,

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。