malloc 에 대한 궁금중.
글쓴이: kicom95 / 작성시간: 수, 2005/03/02 - 9:03오전
안녕하세요 ^^
다름이 아니라 malloc 에 대한 질의를 드리려 합니다.
제가 솔라리스에서는 malloc 을 할때 메모리를
1G 도 할당을 해보고 리눅스도 마찬가지인데.....
잘 되더던데...
AIX 5.1 , 5.2 에서는
ptr = malloc(1024*1024*256) ==> 이건 실패더군요
그런데
ptr = malloc(1024*1024*200) ==> 문제 없이 돌아가던데
물론 이 함수 다음의 메모리 할당 은 안되더군요 -_-;;
각각의 OS 마다 최대 할당 메모리 크기가 따로 있는지요?
아니면 뭐라도 define 을 해야하나요? 대용량 메모리 할당
받으려면 답답해요 -_-;;
제가 짠 프로그램이 메모리가 좀 필요한건데 ^^
Forums:
자문 자답을 해야 겠네요 ^^인터넷을 찾아 보니... 이런 내용이
자문 자답을 해야 겠네요 ^^
인터넷을 찾아 보니... 이런 내용이 있네요
from the users point of view the memory of a program is divided into the
data and the stack region. As far as I know, the AIX compilers limit the
data region size of 32bit executables to 128 MByte, and the stack size
to 32 MByte. To increase the sizes to their maximum value possible for
32bit exes, one links with
-bmaxdata:0x80000000 -bmaxstack:0x10000000
or patches an executable with ldedit, and sets the corresponding
ulimits.
When the data size is too small, malloc fails at runtime with an
appropriate error message. When the stack size is too small, the program
usually crashes with signal 11.
Specifying more than 2 GByte for data size, or more than 256 MByte for
stack size is useless for 32bit executables on AIX and has no effect.
Depending on the data layout for a given application, there exist two
possibilities to overcome memory problems:
1. switch to the 64bit address model
2. use more MPI tasks
The 64bit exes are usually a bit slower than the 32bit executables,
since 64bit pointers have to become fetched from memory or the caches
instead of 32bit pointers, which is a problem of bandwidth.
Using more MPI tasks if memory is not enough was usually a good choice
for Cray T3E and related platforms with good interconnects and memory
bandwidth, if an application distributes data among MPI tasks.
결국 컴파일 옵션을 바꾸니 되는듯 합니다 ^^
나중에 저와 같은 문제를 만나시면 모든 분들 해결 바랍니다.
gcc mem_test.c -Wl,-bmaxdata:0x80000000
가자 해외로 ~ .. 돈 벌러.
댓글 달기