From: Eoin on 2 Jun 2010 12:47 Hi, If I store a .wav file in a variable using wavread() the variable will use up some memory. When I'm finished with that .wav file I can clear the variable but if I want to use the variable again in the near future does setting it equal to 0 free up all the memory it was using, or should I really use clear? Many Thanks
From: Walter Roberson on 2 Jun 2010 12:58 Eoin wrote: > If I store a .wav file in a variable using wavread() the variable will > use up some memory. When I'm finished with that .wav file I can clear > the variable but if I want to use the variable again in the near future > does setting it equal to 0 free up all the memory it was using, or > should I really use clear? Setting a variable to zero does not free up memory (unless the variable was a sparse matrix.)
From: James Tursa on 2 Jun 2010 13:43 Walter Roberson <roberson(a)hushmail.com> wrote in message <C4wNn.85981$jt.66206(a)newsfe04.iad>... > Eoin wrote: > > > If I store a .wav file in a variable using wavread() the variable will > > use up some memory. When I'm finished with that .wav file I can clear > > the variable but if I want to use the variable again in the near future > > does setting it equal to 0 free up all the memory it was using, or > > should I really use clear? > > Setting a variable to zero does not free up memory (unless the variable > was a sparse matrix.) To be clear (no pun intended), I think what you meant was setting the *contents* of a variable to zero does not free up memory. Setting a variable directly to 0 does free up memory because it implicitly does a clear on the old variable. e.g., A = some large array; A(:) = 0; % sets contents to 0's, does not free up memory A = 0; % clears the old A (frees memory) and sets a new A equal to a simple 0 scalar. James Tursa
|
Pages: 1 Prev: Java not clearing from memory? Next: Convert Windows Time to Matlab Time |