0

I have a legacy windows form application (32 bits) where I initialize it in several instances to multi process thousands of data "in parallel".

When I run this manual application (Session 1) using, for example, 8 instances, each instance runs with an average of 200mb of memory usage. That way I don't have a problem with out of memory, because I don't take the risk of an instance exceeding 1,300/1600mb and crashing.

However, when I configure the windows scheduler to run this application via service (Session 0), for some reason, it considers the sum megabytes of all instances, and when it reaches approximately 1,300mb, the application crashes, due to out of memory.

Why is the behavior different between session's regarding memory usage?

memory usage of multiple instances

In Resume:

"You have a 32-bit winforms app ("A.exe") that somehow spawns N child processes (B1, B2, etc...). None of the child processes (Bnn.exe) can exceed 1300MB. When you start A.exe manually (double-clicking), all of the children are OK. When you start A.exe from Windows task manager, all the memory in all the children are counted as belonging to "A.exe"." by @paulsm4

EDIT:

Syntax I used in Windows Task Scheduler to invoke: enter image description here

Code in A.exe that spawns a child process

Call Shell("C:\Test\A.exe login;pass", vbNormalFocus)

Shell is a VB6 function: enter image description here

Diogo Rodrigues
  • 1,312
  • 15
  • 15
  • Q: Can you show us the code in your service where you spawn the process? Or, alternatively, give details as to exactly how you're configuring windows task scheduler (e.g. what is the "command line")? – paulsm4 Jul 01 '22 at 01:31
  • Services are single-instance. – Raymond Chen Jul 01 '22 at 01:31
  • @paulsm4 In the application itself, there is a configuration to define the number of instances and the main instance is responsible for controlling the opening of the other instances. The windows task scheduler is in charge of running the first (main) instance. Its a simple call to Application.exe only – Diogo Rodrigues Jul 01 '22 at 02:04
  • @RaymondChen Interesting, do you have any links where I can be looking at details about this? I've searched but haven't found anything that actually addresses this. – Diogo Rodrigues Jul 01 '22 at 02:07
  • When you `net start` a service and it is already running, you don't get a second copy of the service. You are told the service is already running. – Raymond Chen Jul 01 '22 at 02:09
  • My application.exe its not a service, its a windows forms. A service (scheduler task) start my application.exe. – Diogo Rodrigues Jul 01 '22 at 02:20
  • Okay I misunderstood what you meant by "run this application via service". Are multiple processes running in session zero? Or just one process doing 8 things? – Raymond Chen Jul 01 '22 at 02:36
  • 1
    You have a 32-bit winforms app ("A.exe") that somehow spawns N child processes (B1, B2, etc...). None of the child processes (Bnn.exe) can exceed 1300MB. When you start A.exe manually (double-clicking), all of the children are OK. When you start A.exe from Windows task manager, all the memory in all the children are counted as belonging to "A.exe". Q: Can you show us the syntax you used in Windows Task Scheduler to invoke A.exe? Q: Can you show us the code in A that spawns a child process? For example, CreateProcess()? – paulsm4 Jul 01 '22 at 05:00
  • @RaymondChen one process doing 8 things. – Diogo Rodrigues Jul 01 '22 at 11:24
  • You don't seem to check whether the `Shell` call succeeded. Maybe it's failing, which is why there's only one process: All the other processes failed to start. – Raymond Chen Jul 02 '22 at 13:35

0 Answers0