Recent

Author Topic: [Solved] How to prevent my.exe eat the resources too much?  (Read 1227 times)

d2010

  • New Member
  • *
  • Posts: 28
[Solved] How to prevent my.exe eat the resources too much?
« on: January 30, 2024, 09:07:59 am »
When I start the Cecolord.exe, (always time) , this applications block entire Win7, for
11-12 minutes.
I need the "chiajnax.exe" detect the Cecolord.exe, he calculate the consuming time
of CPU/ hard-disk , and at next start, the "chiajnax.exe", will sets
  • set Afiinity of CPU at last core(I have the solution.pas in source inside Lazarus)
  • usage of RAM too much , Cecolord.exe have a maximum memory usage always running
  • set DiskUsage limit (optional solution)
  • set Internet usage time to much, and Cecolord.exe set internet,usage to minimum if the Cecolord.exe block entire CPU.
  • Chiajnax.exe can run the Cecolord.exe as User not Admin
The main question = this one 1/5
How to Chiajnax.exe can detect the Cecolord or others Acad.exe, BrisCad.exe , far.exe?
 >:(
Eg. fix-Ram-usage= winamp.exe, scandisk.exe, chkdsk.exe, mineswpeer.exe,  mspaint.exe, msconfig.exe
Eg. dynamic-Ram-usage= MsWord,  Acad.exe , SolidWork, Vlc.exe,
Secondary question= how to create of list with apps (with maximum-fix-RAm usage and application with "dynamic-Ram-usage"
 :(
Cecolord.exe create a list with apps_fix-Ram-Usage ;
    dynamic-Ram-usage= All_Apps.exe(minusp)apps_fix-Ram-Usage
 :'(
« Last Edit: January 31, 2024, 11:26:25 am by d2010 »

440bx

  • Hero Member
  • *****
  • Posts: 3857
Re: How to detect my application eat the resources too much?
« Reply #1 on: January 30, 2024, 10:31:47 am »
Before anything, I have to mention that I'm not sure I understood what you are asking for.  What follows are answers based on my guesses of what you are asking for.

How to Chiajnax.exe can detect the Cecolord or others Acad.exe, BrisCad.exe , far.exe?
 >:(
I'm guessing you want a way for that program to determine if Acad.exe, BrisCad.exe and other executables are currently running.  If  that is correct, there are a number of ways of listing the processes, the most common one is using the Toolhelp interface.    I'll give more details if you confirm that this guess is correct.

As far as the RAM a process is consuming, the answer is quite similar, there are a number of APIs that will return that information.  Some of the APIs will return the current working set, the maximum working set and other info.

By the way, those are the APIs used by Process Explorer to display the information it shows.  If you want to see actual code doing it, there is Process Hacker (written in C) that is pretty much a Process Explorer clone.  A great number of questions about how to obtain system information can be answered by studying that code.

As a side note and just FYI, a lot of system information can be obtained using documented APIs but, there is some information that can only be obtained using undocumented APIs mostly residing in ntdll.  The more ambitious you get, the more likely you'll have to deal with undocumented APIs.

HTH.

(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.1 both fixes) on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 13961
  • Probably until I exterminate Putin.
Re: How to detect my application eat the resources too much?
« Reply #2 on: January 30, 2024, 11:55:20 am »
I think he is referring to AutoCad tools, which I should know, but can't see the question. Be more specific.
« Last Edit: January 30, 2024, 11:59:37 am by Thaddy »
Specialize a type, not a var.

d2010

  • New Member
  • *
  • Posts: 28
Re: How to detect my application eat the resources too much?
« Reply #3 on: January 31, 2024, 07:17:55 am »

As far as the RAM a process is consuming, the answer is quite similar, there are a number of APIs that will return that information.  Some of the APIs will return the current working set, the maximum working set and other info.

By the way, those are the APIs used by Process Explorer to display the information it shows.  If you want to see actual code doing it, there is Process Hacker (written in C) that is pretty much a Process Explorer clone.  A great number of questions about how to obtain system information can be answered by studying that code.
HTH.

The solution1inside mind= "chiajnax.exe" calculate sumtime=time_consuming_CPU+calculate_time_Harddisk+calculate_total_RAM?
(Foreach APP from "applist'  if sumtime>0.30*time_clock then chiajanx.exe slowdown the app)
About Acad.exe are too powerfull , "chiajnax.exe" cannot "calibrate-internal-speed of Acad.exe".
 :(
The solution2inside cmd.exe=" chiainax,exe running cecolord.exe with low-resource+minimCoreOf_Cpu+minimHard_disk
   winexec("cecolord.exe" ,5, MINIM_RES_FLAG+NOWAIT)
?? Because are too many  undocumented APIs., I need only,  the answer "solution2inside cmd.exe"?
Thank you



« Last Edit: January 31, 2024, 07:23:37 am by d2010 »

440bx

  • Hero Member
  • *****
  • Posts: 3857
Re: How to detect my application eat the resources too much?
« Reply #4 on: January 31, 2024, 07:43:09 am »
Again, I have to state upfront that it is unlikely that I understood what you meant correctly but, I'm going to guess that you want  some way to limit the amount of CPU that will be given to one or more processes.

If that guess is correct then a possibility that comes to mind is to lower the application's priority.   A "low priority" or "idle priority" app will usually consume less CPU than an app running at a higher priority.

MS explains how to manage priorities in the page https://learn.microsoft.com/en-us/windows/win32/procthread/scheduling-priorities

You could easily write a command line program to manage process priorities.  That said, both, Process Explorer and Process Hacker allow you to manage process priorities therefore you might not need to write your own program to duplicate that functionality.

As far as controlling the amount of RAM a process uses, for the most part, there is no way to control that.  Normally, Windows will do whatever it can to satisfy a program's memory requirements.  The most you can do is "supervise" how much it uses at a particular time.

HTH.

(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.1 both fixes) on Windows 7 SP1 64bit.

d2010

  • New Member
  • *
  • Posts: 28
Re: How to prevent my application eat the resources too much?
« Reply #5 on: January 31, 2024, 11:18:46 am »
That is the finally-needs.
Thank you, thank you user440bx
Please you mark "SOLVED" this topic.
MS explains how to manage priorities in the page https://learn.microsoft.com/en-us/windows/win32/procthread/scheduling-priorities
HTH.
God bless your familly440bx.
God bless your familly440bx.
God bless your familly440bx.
« Last Edit: January 31, 2024, 11:24:17 am by d2010 »

 

TinyPortal © 2005-2018