Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Calculate Memory

Subject: Calculate Memory

From: fiza khalid

Date: 25 Jun, 2010 18:44:22

Message: 1 of 9

i want to calculate the memory used by my function which i am try to run in matlab
can anyone help me to try this.which function is used for memory display please tell me if someone knows about it.
thanx in advance.

Subject: Calculate Memory

From: Matt J

Date: 25 Jun, 2010 19:10:11

Message: 2 of 9

"fiza khalid" <princess.2050@hotmail.com> wrote in message <i02te6$8bm$1@fred.mathworks.com>...
> i want to calculate the memory used by my function which i am try to run in matlab
> can anyone help me to try this.which function is used for memory display please tell me if someone knows about it.
> thanx in advance.
===========

Your problem is not fully formulated because the "memory used by a function" is not a well-defined thing.

In MATLAB, a variable in a function's workspace can share memory with other variables that reside either in the same workspace or outside of it. So, how would you define which blocks of memory that a given function owns?

Subject: Calculate Memory

From: Jan Simon

Date: 25 Jun, 2010 19:30:31

Message: 3 of 9

Dear Fiza,

> i want to calculate the memory used by my function which i am try to run in matlab
> can anyone help me to try this.which function is used for memory display please tell me if someone knows about it.

See:
  whos
  feature memstats
FEX: http://www.mathworks.com/matlabcentral/fileexchange/26662

Good luck, Jan

Subject: Calculate Memory

From: dpb

Date: 25 Jun, 2010 19:52:20

Message: 4 of 9

fiza khalid wrote:
> i want to calculate the memory used by my function which i am try to run
> in matlab
> can anyone help me to try this.which function is used for memory display
> please tell me if someone knows about it.
> thanx in advance.

Probably best thing would be to look at output of the "WHO" or "WHOS"
command before and during and after your function to get a feel for what
memory was allocated during and retained after calling the function in
question.

doc whos % and friends

--

Subject: Calculate Memory

From: fiza khalid

Date: 4 Jul, 2010 11:20:07

Message: 5 of 9

"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <i02uuj$ggv$1@fred.mathworks.com>...
> "fiza khalid" <princess.2050@hotmail.com> wrote in message <i02te6$8bm$1@fred.mathworks.com>...
> > i want to calculate the memory used by my function which i am try to run in matlab
> > can anyone help me to try this.which function is used for memory display please tell me if someone knows about it.
> > thanx in advance.
> ===========
>
> Your problem is not fully formulated because the "memory used by a function" is not a well-defined thing.
>
> In MATLAB, a variable in a function's workspace can share memory with other variables that reside either in the same workspace or outside of it. So, how would you define which blocks of memory that a given function owns?
>>i want to know how much processor memory is being used while i am running my program not the single variable memory but the as a whole memory taken by my program how can i do that.help me.

Subject: Calculate Memory

From: Faraz Afzal

Date: 4 Jul, 2010 11:45:08

Message: 6 of 9

"fiza khalid" <princess.2050@hotmail.com> wrote in message <i0pqp7$m89$1@fred.mathworks.com>...
> "Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <i02uuj$ggv$1@fred.mathworks.com>...
> > "fiza khalid" <princess.2050@hotmail.com> wrote in message <i02te6$8bm$1@fred.mathworks.com>...
> > > i want to calculate the memory used by my function which i am try to run in matlab
> > > can anyone help me to try this.which function is used for memory display please tell me if someone knows about it.
> > > thanx in advance.
> > ===========
> >
> > Your problem is not fully formulated because the "memory used by a function" is not a well-defined thing.
> >
> > In MATLAB, a variable in a function's workspace can share memory with other variables that reside either in the same workspace or outside of it. So, how would you define which blocks of memory that a given function owns?
> >>i want to know how much processor memory is being used while i am running my program not the single variable memory but the as a whole memory taken by my program how can i do that.help me.


Dear Fiza,

I am of the view that you still need to elaborate your question more. Let me go through the series of questions you asked:

>>i want to know how much processor memory is being used while i am running my program
                        Processor Memory , ?? Is that CPU Cache memory being utilised OR it is PIM you are interested in?? IF THIS is what you asked then MATLAB does not make use of these memories. !!! Secodly as it sounds to me you are asking abt the variable space , variable memory tehn within your function let your variables be published to cmd, and you will check all the stuff with whos command. This step is necessary as I know MATLAB has function variable space that is not shared with command variables workspace, and fucntion variable space is flushed right after the execution is completed.

Lastly is that you are interested in CPU resources being used when you run your program ? Answer is they are same as used by MATLAB as a whole + variable spaces being called dynamically.

Very lastly if you need to know the whole resources memory etc etc being used by your function only you will need to make a standalone application and then run it to find out.
 It would have been better if you explained your problem a little more.

I hope it helps,
Regards,
Muhammad Faraz

Subject: Calculate Memory

From: ImageAnalyst

Date: 4 Jul, 2010 11:46:17

Message: 7 of 9

Sorry if I'm asking something really obvious that you've already
tried, but (since you didn't mention it) did you try the memory
command?

myMemory = memory % myMemory will be a structure.

myMemory =
    MaxPossibleArrayBytes: 947585024
    MemAvailableAllArrays: 1.4247e+009
            MemUsedMATLAB: 451756032

Subject: Calculate Memory

From: us

Date: 4 Jul, 2010 12:27:05

Message: 8 of 9

"fiza khalid" <princess.2050@hotmail.com> wrote in message <i02te6$8bm$1@fred.mathworks.com>...
> i want to calculate the memory used by my function which i am try to run in matlab
> can anyone help me to try this.which function is used for memory display please tell me if someone knows about it.
> thanx in advance.

a hint:
- PROFILE shows you all you want (and more) if you unleash some if its
  undoc strength...

% edit your STARTUP.M
% add these commands
     setpref('profiler','showJitLines',1);
     profile -memory on;
     profile off;
% now, PROFILE your function and look at all the information you get...

us

Subject: Calculate Memory

From: fiza khalid

Date: 5 Jul, 2010 10:03:04

Message: 9 of 9

"Faraz Afzal" <farazafzal@gmail.com> wrote in message <i0ps84$pfu$1@fred.mathworks.com>...
> "fiza khalid" <princess.2050@hotmail.com> wrote in message <i0pqp7$m89$1@fred.mathworks.com>...
> > "Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <i02uuj$ggv$1@fred.mathworks.com>...
> > > "fiza khalid" <princess.2050@hotmail.com> wrote in message <i02te6$8bm$1@fred.mathworks.com>...
> > > > i want to calculate the memory used by my function which i am try to run in matlab
> > > > can anyone help me to try this.which function is used for memory display please tell me if someone knows about it.
> > > > thanx in advance.
> > > ===========
> > >
> > > Your problem is not fully formulated because the "memory used by a function" is not a well-defined thing.
> > >
> > > In MATLAB, a variable in a function's workspace can share memory with other variables that reside either in the same workspace or outside of it. So, how would you define which blocks of memory that a given function owns?
> > >>i want to know how much processor memory is being used while i am running my program not the single variable memory but the as a whole memory taken by my program how can i do that.help me.
>
>
> Dear Fiza,
>
> I am of the view that you still need to elaborate your question more. Let me go through the series of questions you asked:
>
> >>i want to know how much processor memory is being used while i am running my program
> Processor Memory , ?? Is that CPU Cache memory being utilised OR it is PIM you are interested in?? IF THIS is what you asked then MATLAB does not make use of these memories. !!! Secodly as it sounds to me you are asking abt the variable space , variable memory tehn within your function let your variables be published to cmd, and you will check all the stuff with whos command. This step is necessary as I know MATLAB has function variable space that is not shared with command variables workspace, and fucntion variable space is flushed right after the execution is completed.
>
> Lastly is that you are interested in CPU resources being used when you run your program ? Answer is they are same as used by MATLAB as a whole + variable spaces being called dynamically.
>
> Very lastly if you need to know the whole resources memory etc etc being used by your function only you will need to make a standalone application and then run it to find out.
> It would have been better if you explained your problem a little more.
>
> I hope it helps,
> Regards,
> Muhammad Faraz
>>Thnx for your response
>>actually i am doing a comparison of two algorithms so that's why i need to know the cpu resources used by each algo in matlab i am checking them with respect to time and memry.so i have done with time but confused while doing with memory as in matlab i dont know how to do that without that WHOS commant as it gives only varaible space not whole function memory.i hope ou will understand my problem and help me.
thnx.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us