Results 1 to 2 of 2

Math Help - Matlab - memmapfile Memory Usage, what's wrong?

  1. #1
    Newbie
    Joined
    Feb 2009
    Posts
    1

    Matlab - memmapfile Memory Usage, what's wrong?

    Hello,

    In a function I'm mapping a ~30MB file like this:

    Code:
    raw = memmapfile( ...
        sFileName, ...
        'Offset', iOffsetToData, ...
        'Format', { ...
            'int32' [1 3] 'a'; ... 
          
            'uint16' [1 1] 'b'; ...
            
            'uint8' [1 1] 'c'; ...
                                                                          
            'uint8' [1 1] 'chClassification'; ...
                                     
            
            'int8' [1 1] 'chScanAngleRank';  ...
                                      
            
            'uint8' [1 1] 'chFileMarker';  ...
                                      
            
            'uint16' [1 1] 'rvUserBitField'; ...
            
            'double' [1 1] 'o'; ... 
                                    
            } ...
        );
    All good.

    now I want to read the data so I write:

    Code:
    myData=raw.Data;

    Now there are huge problems. Matlab goes from 300MB to 2.5GB of memory usage.

    whos mydata returns 1.2GB. (How is this even possible?)

    I do some computing and return a matrix that should be about 40MB.

    End of function.


    So, fine, I thought, the function is finished and matlab deallocates the memory it used. But no, it doesn't. I tried clearing it up manually in the function, but nothing happens. I also tried reading raw.Data(k).a in a loop, but Matlab appears to create the whole raw.Data array anyway.

    My biggest concern is that most computers won't handle the huge mem requirement increase. It is just too much. How can I fix it?

    I'm sure I can skip this memmapfile-method altogether, and use some read file function, but it's slower. Is it possible to read custom structures from files (as with the ease of memmapfile)?
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Bar0n janvdl's Avatar
    Joined
    Apr 2007
    From
    Meh
    Posts
    1,630
    Thanks
    6
    Maybe this could be of help? MATLAB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Memory Refreshing
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: November 7th 2010, 11:29 AM
  2. What is wrong with my matlab function?
    Posted in the Math Software Forum
    Replies: 1
    Last Post: October 26th 2010, 11:29 PM
  3. Replies: 1
    Last Post: February 9th 2010, 03:29 AM
  4. wrong code at matlab - meshgrid and 3d plot
    Posted in the Math Software Forum
    Replies: 2
    Last Post: June 30th 2009, 12:17 AM
  5. MATLAB - Usage of Zeros?
    Posted in the Math Software Forum
    Replies: 0
    Last Post: February 17th 2009, 05:07 PM

Search Tags


/mathhelpforum @mathhelpforum