File Exchange

image thumbnail

Display ws variables size in KB, MB or GB

version 1.6 (3.49 KB) by

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

3 Downloads

Updated

View License

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

SYNTAXES:
(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.
p7v5

Comments and Ratings (10)

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.

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!

Casper

Casper (view profile)

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?

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.

Rob Campbell

Rob Campbell (view profile)

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

Oleg Komarov

Oleg Komarov (view profile)

Andy,
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..

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.

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.
Oleg

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 http://undocumentedmatlab.com/blog/customizing-matlabs-workspace-table/ for how to display similar results in the Workspace Panel table.

Updates

1.6

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

1.5

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

1.4

From 'base' to 'caller' size display.

1.3

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

1.1

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

MATLAB Release
MATLAB 7.9 (R2009b)

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

» Watch video