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

Friedrich
Friedrich 2012년 9월 6일
편집: Friedrich 2012년 9월 6일
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
Jan 2012년 9월 6일
@friedrich: No, pre-allocation is only useful, if the allocated memory block is used later.

댓글을 달려면 로그인하십시오.

답변 (2개)

Jan
Jan 2012년 9월 6일
편집: Jan 2012년 9월 6일

1 개 추천

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
Robin 2012년 9월 7일

0 개 추천

Thanks for your answer. I really need the matrix to be in 1 object since i need to do some 3D connected component analysis for segmentation. I know that the free memory is fragmented.
@ friedrich : i don't even load the image. By even cancelling the UI, by just pressing cancel at selecting a file the memory is substantially fragmented.
So is there any way to prevent that uigetfile ( i only need path-file name ) fragments the memory so badly?

댓글 수: 2

Jan
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
Walter Roberson 2012년 9월 7일
And switch to the 64 bit version of MATLAB.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

질문:

2012년 9월 6일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by