title: Access violation occurs using tbb::allocator<T>.allocate
body: <p>I am trying to use TBB to boost the performance of a computer vision project which uses OpenCV. Here is the part in the code which gives access violation. </p>
  
  <pre><code>#include &lt;opencv/cv.h&gt;
  #include "opencv2/objdetect/objdetect.hpp"
  #include "opencv2/highgui/highgui.hpp"
  #include "opencv2/imgproc/imgproc.hpp"
  #include "tbb/pipeline.h"
  #include "tbb/tick_count.h"
  #include "tbb/task_scheduler_init.h"
  #include "tbb/tbb_allocator.h"
  #include &lt;iostream&gt;
  using namespace cv;
  using namespace std;
  int main()
  {
      string file = "myimage.jpg";
      Mat* mats2=tbb::tbb_allocator&lt;Mat&gt;().allocate(100);
      for (int i = 0 ; i &lt; 100 ; ++i)
      {
          mats2[i]=imread(file);         &lt;===== Access Violation
          imshow("temp",mats3[i]);
          waitKey(1);
      }
  }
  </code></pre>
  
  <p>Why is this an Access Violation? Mats2 is not 0 and is definitely assigned to an address in memory. I know other functions from this <a href="http://threadingbuildingblocks.org/docs/doxygen/a00426.html" rel="nofollow" title="here">link</a> that I can use but I want to know what happens in tbb_allocator that leads to this error. The code doesn't give error if used with malloc or scalable_malloc. </p>