From: CSB on
I was trying to assess the memory requirements of some code and came across something that makes no sense to me. Unfortunately I can't provide the code needed to reproduce this but I'm hopeful that my description will be enough for someone to know what's going on here. Here's what I'm seeing from a fresh re-start of MATLAB:

---------------------------- BEGIN --------------------------------------

>> global globalVar
>> memory
Maximum possible array: 1494 MB (1.567e+009 bytes) *
Memory available for all arrays: 2594 MB (2.720e+009 bytes) **
Memory used by MATLAB: 230 MB (2.413e+008 bytes)
Physical Memory (RAM): 3582 MB (3.756e+009 bytes)

* Limited by contiguous virtual address space available.
** Limited by virtual address space available.

>> codeToCreateAndFillGlobalVar()
>> whos('globalVar')
Name Size Bytes Class Attributes

globalVar 1x1 2147483647 struct global
>> memory
Maximum possible array: 1207 MB (1.266e+009 bytes) *
Memory available for all arrays: 2544 MB (2.667e+009 bytes) **
Memory used by MATLAB: 282 MB (2.953e+008 bytes)
Physical Memory (RAM): 3582 MB (3.756e+009 bytes)

* Limited by contiguous virtual address space available.
** Limited by virtual address space available.

---------------------------- END --------------------------------------

So, how is this possible?! I create a global variable that consumes over 2GB but the memory used by MATLAB increases by only 52 MB. More than that, it appears to be accurate in that I am still able to create matrices that fill the 2+ GB reported as available.

What am I missing?
From: Loren Shure on
In article <hq2hu0$lm3$1(a)fred.mathworks.com>, cbrundick(a)hotmail.com
says...
> I was trying to assess the memory requirements of some code and came across something that makes no sense to me. Unfortunately I can't provide the code needed to reproduce this but I'm hopeful that my description will be enough for someone to know what's going on here. Here's what I'm seeing from a fresh re-start of MATLAB:
>
> ---------------------------- BEGIN --------------------------------------
>
> >> global globalVar
> >> memory
> Maximum possible array: 1494 MB (1.567e+009 bytes) *
> Memory available for all arrays: 2594 MB (2.720e+009 bytes) **
> Memory used by MATLAB: 230 MB (2.413e+008 bytes)
> Physical Memory (RAM): 3582 MB (3.756e+009 bytes)
>
> * Limited by contiguous virtual address space available.
> ** Limited by virtual address space available.
>
> >> codeToCreateAndFillGlobalVar()
> >> whos('globalVar')
> Name Size Bytes Class Attributes
>
> globalVar 1x1 2147483647 struct global
> >> memory
> Maximum possible array: 1207 MB (1.266e+009 bytes) *
> Memory available for all arrays: 2544 MB (2.667e+009 bytes) **
> Memory used by MATLAB: 282 MB (2.953e+008 bytes)
> Physical Memory (RAM): 3582 MB (3.756e+009 bytes)
>
> * Limited by contiguous virtual address space available.
> ** Limited by virtual address space available.
>
> ---------------------------- END --------------------------------------
>
> So, how is this possible?! I create a global variable that consumes over 2GB but the memory used by MATLAB increases by only 52 MB. More than that, it appears to be accurate in that I am still able to create matrices that fill the 2+ GB reported as available.
>
> What am I missing?
>

maybe you created the struct where the fields share data between them
implicitly, until the values differ? Depends on
codeToCreateAndFillGlobalVar details...

--
Loren
http://blogs.mathworks.com/loren
http://matlabwiki.mathworks.com/MATLAB_FAQ