title: Wt c++ critical error when creating WApplication object
body: <p>I have problem with my Wt web application. It's rather simple app, I do not need to deploy it on any external server (only localhost), so built in whttpd server provided by framework is sufficient for my needs. I create an executable file in release mode (Visual Studio 2015), run it, and when I open localhost:8080 in browser to access application, I get an error. In debug mode however everything works well.</p>
  
  <p>Debug console shows this:</p>
  
  <blockquote>
    <p>Exception thrown at 0x00007FFB08477788 in
    Neural_network_visualisation.exe: Microsoft C++ exception:
    std::runtime_error at memory location 0x00000025E30FB408.</p>
    
    <p>Critical error detected c0000374 </p>
    
    <p>Neural_network_visualisation.exe has triggered a breakpoint.</p>
  </blockquote>
  
  <p>main.cpp</p>
  
  <pre><code>#include "MyApplication.h"
  #include "MyContainerWidget.h"
  
  WApplication *createApplication(const WEnvironment&amp; env) //exception is thrown here
  {
      Wt::WApplication *app = new Wt::WApplication(env); //error c0000374
      app-&gt;setCssTheme("polished");
      new MyContainerWidget(app-&gt;root());
  
      return app;
  }
  
  int main(int argc, char **argv)
  {
      return WRun(argc, argv, &amp;createApplication);
  }
  </code></pre>
  
  <p>The exception is thrown just after entering createApplication function, but the program doesn't crash there. After executing first line critical error is shown and application stops. </p>
  
  <p>The code is so simple that I can't see any problem with it. My guess is that release mode expects some special configuration to work with Wt, but official documentation doesn't mention anything more is needed while using built-in http server. Can anybody with Wt experience help me with this?</p>
  
  <p>Edit 1:</p>
  
  <p>I changed my code so it looks like this:</p>
  
  <pre><code>#include "MyApplication.h"
  #include "MyContainerWidget.h"
  
  WApplication *createApplication(const WEnvironment&amp; env)
  {
      //Wt::WApplication *app = 
  //  app-&gt;setCssTheme("polished");
      //new MyContainerWidget(app-&gt;root());
  
      return new Wt::WApplication(env);;
  }
  
  int main(int argc, char **argv)
  {
      return WRun(argc, argv, &amp;createApplication);
  }
  </code></pre>
  
  <p>Now the error is different and states:</p>
  
  <blockquote>
    <p>HEAP[Neural_network_visualisation.exe]: Invalid address specified to
    RtlValidateHeap( 000002A04F550000, 000002A05117F060 )</p>
  </blockquote>
  
  <p>So this is a memory management problem. In debug mode this management works quite different than in release, that's why I do not get any error while in debug. Unfortunately, I still do not know how to fix this. Any ideas?</p>