<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/257078</link>
    <title>MATLAB Central Newsreader - Managing memory in parfor loops</title>
    <description>Feed for thread: Managing memory in parfor loops</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Mon, 27 Jul 2009 19:28:39 -0400</pubDate>
      <title>Managing memory in parfor loops</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/257078#668541</link>
      <author>Bryan Heit</author>
      <description>I am working on some scripts to preform image analysis on folders&lt;br&gt;
containing multiple images.  To speed things along I am using parfor&lt;br&gt;
loops (the results of one images' analysis does not affect the&lt;br&gt;
analysis of any other images, so this should work).&lt;br&gt;
&lt;br&gt;
The problem I am having is that each analysis cycle generates fairly&lt;br&gt;
large arrays of data that are only needed for a small portion each&lt;br&gt;
analysis loop (basically arrays storing intermediary values).  Before&lt;br&gt;
using the parfor (when I was just using for loops) I would clear these&lt;br&gt;
arrays once I was done with them, as to avoid potential memory&lt;br&gt;
overflow.  However, when I do this in parfor loops, I get the&lt;br&gt;
following caution:&lt;br&gt;
&lt;br&gt;
&quot;The function CLEAR might make an invalid workspace access inside the&lt;br&gt;
parfor loop.&quot;&lt;br&gt;
&lt;br&gt;
What I am wondering is if this means the 'clear' command will clear&lt;br&gt;
the variable in all of the cores (threads?)  being used for parallell&lt;br&gt;
processing, rather than in just the one core/thread where the clear&lt;br&gt;
command is being called.  By which I mean, if I'm using a dual-core&lt;br&gt;
machine (with cores 'a' and 'b'), calling 'clear' on 'a' will also&lt;br&gt;
clear the same variable in 'b'.&lt;br&gt;
&lt;br&gt;
If the above is the case, is there another command that clears the&lt;br&gt;
variable only in one core/thread?&lt;br&gt;
&lt;br&gt;
Thanx&lt;br&gt;
&lt;br&gt;
Bryan</description>
    </item>
  </channel>
</rss>

