View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Display ws variables size in KB, MB or GB

4.6 | 5 ratings Rate this file 9 Downloads (last 30 days) File Size: 3.49 KB File ID: #26250 Version: 1.6
image thumbnail

Display ws variables size in KB, MB or GB


Oleg Komarov (view profile)


02 Jan 2010 (Updated )

Displays with appropriate unit of data storage. Sorting by size/name (non c.sensitive) is supported.

| Watch this File

File Information

Display in command window the size of the variables of the base workspace using KB, MB and GB

(1) WSSIZE Display preserving the order of the workspace pane using mixed units
(2) WSSIZE arg or WSSIZE('arg') One argument syntax
(3) WSSIZE arg1 arg2 or WSSIZE('arg1','arg2') Two arguments syntax

From p7v5 displays the grand total.

Arguments: should be char; max two arguments are allowed. Arguments are not case-sensitive.The order of the two types of arguments doesn't matter. Shortened arguments can be supplied ('s' instead of 'size').

For details see help
For examples see the attached image.

Aknowledgments: original idea by Bastiaan Zuurendonk, TMW technical support engineer. Implemented suggestions by Yair Altman (see comments)

Comments/suggestions/error reports are welcome.

MATLAB release MATLAB 7.9 (R2009b)
Other requirements Tested on R14SP3 (7.1) and on R2009b. In-between compatibility is assumed.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (10)
12 Dec 2016 Oleg Komarov

Oleg Komarov (view profile)

@Mirsad happy you like it! You can also simply write: wssize m s.

Saves you the effort of writing quotes and parentheses.

Comment only
12 Dec 2016 Mirsad Tulic

The variant wssize('MB','size') is great!! Clearly arranged and in MB, so the larger variables are seen very nicely at the end.
Thanks to Oleg!

17 Sep 2013 Casper

Casper (view profile)

17 Feb 2010 Oleg Komarov

Oleg Komarov (view profile)

You're suggestion to subject the Grand Total to the reverse sorting behaviour?...I'd implement it always as the last entry because when you have many variables the listing on the screen scrolls down a lot...and I'd like to know at a glance how much memory I'm using. Revsorting would flip GT on top and i would miss it...

What about
a: 432 KB
b: 23 KB
T: 455 KB

Where "a" and "b" are subject to the sorting while T: is not?

Comment only
17 Feb 2010 Michael

Nice and usefull tool. Exactly what I was looking for. I would also find an entry "Grand Total" helpful, for example by adding the lines
ws_contents(end+1,:) = { 'Grand Total', sum( cell2mat(ws_contents(:,2)) )};
numVars = numVars+1;
after line 95.

16 Jan 2010 Rob Campbell

Rob Campbell (view profile)

Always wanted this behaviour from whos. Glad to find this file.

08 Jan 2010 Oleg Komarov

Oleg Komarov (view profile)

you're are totally right if syntax consistancy is what we are looking for...and it may be, but when I set the default behavior for the size sorting method I was thinking that maybe displaying first the biggest vars would save some time (if you already have 50 other vars and to see them all scrolling is needed).
On the other hand as you say 'wssize -s' isn't that different from 'wssize s'...I simply didn't want to write every time '-s' (since i'm inerested in many cases in large vars.).
To make it consistent accross methods or not...this is my dilemma..

Comment only
07 Jan 2010 Andy

Andy (view profile)

A minor point: I would switch the size and -size flags so that wssize size sorts from smallest to largest. This is consistent with wssize name sorting in ascending order and wssize -name sorting in descending order.

Comment only
07 Jan 2010 Oleg Komarov

Oleg Komarov (view profile)

Thanks Yair for the comments (of course I will implement your java suggestion, since that was what I wanted specifically to achieve, still this fcn remains useful)
The features suggested by Yair are being uploaded. Additionally, the workspace variables whose data size will be displayed will change from 'base' to 'caller', making it possible to display the size of the variables during debug. Other updates will be notified in the update frame (below) and inside the fcn. Compatibility unchanged.

Comment only
05 Jan 2010 Yair Altman

Yair Altman (view profile)

Nice and useful implementation.

I suggest adding reverse sorting by simply prepending '-' (for example: '-size'). I also suggest adding an option to display all the sizes in a particular format (for example: 'KB' or 'MB').

Also see for how to display similar results in the Workspace Panel table.

05 Jan 2010 1.1

Edited description; Added sorting by not case-sensitive name; Aknowledgments for Bastiaan Zuurendonk (TMW technical support engineer)

06 Jan 2010 1.3

Added reverse sorting and unit selection on suggestion by Yair Altman. Edited help. Added more checks.

07 Jan 2010 1.4

From 'base' to 'caller' size display.

15 Jan 2010 1.5

Now 'size' sorts from smallest to biggest. Suggestion by Andy.

22 Feb 2010 1.6

Per Michael suggestion added grand total at the bottom. Restructured code.

Contact us