title: How to solve: RenderEventToBuffer failed because of insufficient memory - Windows Scheduled Task
body: <p><em>Windows 2008 R2 server, 16G ram. MS SQL 2012, Max server mem set to 12G (not sure if the SQL info is relevant).</em></p>
  
  <p>I have an exe that has a function which can be run manually (click the button) or via a scheduled task (passing the correct param).</p>
  
  <p>When the task gets run manually, all works fine.</p>
  
  <p>When the task is run as a scheduled task, I get the following error:</p>
  
  <pre><code>RenderEventToBuffer failed because of insufficient memory -122-The data area passed to a system call is too small
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/zQtWI.png" alt="RenderEventToBuffer"></p>
  
  <p>** The one thing that might be a hint OR could be a red herring, is that it seems after the sql server is restarted (and much less than it's 12G limit in memory) the scheduled task runs fine, but the error appears once the sql server hits the 12G memory limit.</p>
  
  <p>As I write that, it really does seem red-herring-ish, but I don't know enough to know enough.</p>
  
  <p><strong>Can anyone help me understand what this means and how to solve it?</strong></p>