memory lost (allocated) by uigetfile
이전 댓글 표시
Dear matlab users, I work on large CT images 512x512x234, so i need a lot of memory. However, when i want the use to be able to select a file i lose a lot of allocated memory. when i restart matlab :
>>memory Maximum possible array: 1239 MB (1.299e+009 bytes) *
Then by ONLYusing the command [file path]=uigetfile({'*.img'},'Get .img file'); i lose the memory (not even loading the image):
>> memory Maximum possible array: 987 MB (1.035e+009 bytes) *
I really need the UI to have the user select a file instead of copy pasting the path and filename. Does anybody have an idea how to solve this? or another whay to selec t the file/path name? (Pack doesn't work)
Thanks!
edit: sometimes i even lose 400 MB without even selecting a file (cancel the UI). By the way, i'm working with Matlab 7.10.0 (R2010a)
댓글 수: 2
Maybe allocate the memory for the image first and then call uigetfile. So something like
tmp = zeros(512,512,234) %maybe allocate it as uint8 directly
uigetfile(...)
Jan
2012년 9월 6일
@friedrich: No, pre-allocation is only useful, if the allocated memory block is used later.
답변 (2개)
The command uigetfile does not leak memory. But the free memory is fragmented. To store a large array (of en elemtary type like DOUBLE or UINT8), the the memory must be available as an contiguous block. If you have 1 GB before calling a function, and one single scalar is created and stored exactly in the center of the free block, only 0.5 GB can be used for storing a large array afterwards, although 1.0GB - about 100 Bytes are free.
Therefore your 512x512x234 images could be stored more efficiently as {1 x 234} cell of [512 x 512] matrices.
Robin
2012년 9월 7일
0 개 추천
댓글 수: 2
Jan
2012년 9월 7일
Please post comments as comments, not in the answer section.
No, you cannot influence the memory manager reliably. There have been some startup parameters, which enable different strategies for the memory management, and you can clear the Java heap. The most efficient workaround would be to install more RAM.
Walter Roberson
2012년 9월 7일
And switch to the 64 bit version of MATLAB.
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!