Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have a multi threaded application. In order for the memory manager to work, multi-threaded applications must set <a href="http://docwiki.embarcadero.com/Libraries/en/System.IsMultiThread" rel="nofollow noreferrer"><code>IsMultiThread</code></a> to <code>True</code>. This will happen if you base your threads on <code>TThread</code>.</p> <p>From the <a href="http://docwiki.embarcadero.com/Libraries/en/System.IsMultiThread" rel="nofollow noreferrer">documentation</a>:</p> <blockquote> <p>IsMultiThread is set to True to indicate that the memory manager should support multiple threads. IsMultiThread is set to True by BeginThread and class factories.</p> </blockquote> <p>Because you are calling the raw Windows API <code>CreateThread</code>, and not using the RTL supported thread routines, nothing in the system sets <code>IsMultiThread</code> to <code>True</code>. And so the memory manager assumes that there is only a single thread, and does not lock access to the memory manager's shared data structures. Hence the problems you observed.</p> <p>If you simply set <code>IsMultiThread := True</code> at startup, your code will work perfectly. Or switch to using a <code>TThread</code> based thread.</p> <p>Note that your issue has nothing at all to do with Indy. You can see this failure simply by allocating heap memory in the thread. This program dies every time on my system:</p> <pre><code>{$APPTYPE CONSOLE} uses SysUtils, Windows; function HttpRequest(AParam : Integer): DWORD; stdcall; var i: Integer; P: Pointer; begin Result := 0; for i := 1 to 100000 do GetMem(P, 1); end; var i: Integer; tid: DWORD; begin try //IsMultiThread := True;//include this line to make program correct for i := 0 to 15 do CreateThread(nil, 0, @HttpRequest, nil, 0, tid); except on E:Exception do Writeln(E.Message); end; Readln; end. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload