Access Violation in a Multithreaded Application on Windows Server 2003

I have an application (using Delphi 2009) that allows a user to run a query on selected systems, and then combines the results into a single report.

Short description of the application: The
user selects a request and a group of systems to execute the request. The query is executed on all systems simultaneously, creating a new thread to start the query and using TADOQuery to actually execute the query from the thread. When the query is completed, TADOQuery.SaveToFile is called, passing pfXML as a parameter to store the results in an XML document. After completing all requests, the application parses all XML documents and combines them into one XML document. The user can then load the report, which calls TADOQuery.LoadFromFile to load the report and display it in the TListView.

So that the user does not overload the PC, sending too many requests (thereby launching too many threads), I implemented the queue using an array of records. Each entry contains information such as the name of the request, system, status (start, end, or wait), etc. Another reason for implementing the queue is that the user can send multiple requests at the same time (i.e. they don’t need to wait for the first to complete before sending another). An array of records is probably not the most efficient way to implement a queue, but it works. I save the number of simultaneously running threads to 100 (this can be changed by the user) and start new threads when they are completed, synchronizing the completion of the request in the thread with the procedure that controls the queue.In no case does memory usage increase by about 25-30K.

, , , , . , .

:
Windows XP. , . , Windows Server 2003, . ( ) . , , .

, - , , . , FastMM4 , - , - , , , , , , .

, temp ( , , , ). , , , ( 100) ( , 20 ).

, , , ( ). , , , , , , temp . , , .

:
1. ? - , - ? 2. Windows XP, Windows Server 2003?

UPDATE
, Windows XP, Windows Server 2003. , Windows Server 2003 a , XP.

, , , , , ( ) ( , , 0).

callstack MadExcept, - , .

- , ( ), , , .

+3
2

- , , !

TADOQuery, . , , , :

adoqry := TADOQuery.create(frmMain);
try
  <code>
finally
  freeAndNil(adoqry);
end;

, , TADOQuery, , , , , , , , .

TADOQuery nil, , ( ).

0

, ... β„– 2 ? ( ). , , - /. , ( ).

0

Source: https://habr.com/ru/post/1777655/


All Articles