Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QM Memory
#1
I have an automation machine running a lot of various scheduled tasks by calling QM functions throughout the day.

QM memory usage will continue to grow and grow (it does sometimes go down), but eventually it will start throwing errors about not having enough memory to run functions.

When trying to close QM it will have an error about not having enough memory to save the file.

Is there something I can do to free up QM memory when a function completes or is there something else that is at play here?

It is a little troublesome because it always does it when I take a day off...so then I get a call about things not working.

-jim
#2
Normally should not grow. On my PC QM often runs several days, and memory usage never grows above 20 MB.

Maybe some macros allocate and don't release memory. QM functions and variables (str, ARRAY, COM interface and other) release memory automatically. With some functions, eg Windows API functions, need to explicitly release memory, close handle, etc.

Of course can be a bug in some QM function too. Or in a dll or COM component.

If you have many macros, it is difficult to find memory leaks. I'll try to create a memory leak detector for QM.

If you suspect some macros, try to run them in separate process, if possible.
#3
Is there a way to force QM to restart if memory goes above a threshold?

-jim
#4
Function GetQmMemoryUsage
Code:
Copy      Help
;/
function#

;Returns QM memory usage, KB.
;It is what you see in Task Manager, "Commit Size" column.


PROCESS_MEMORY_COUNTERS z.cb=sizeof(z)
if GetProcessMemoryInfo(GetCurrentProcess &z sizeof(z))
,ret z.PagefileUsage/1024
#5
Hello,

I tried to use this function to get memory of another process using an int but no luck. 

    int cors=ProcessNameToId2("CorsairLink4.exe" 0 1)
    if(cors)

How can I get the memory of another process??

Rob
#6
Function GetProcessMemoryUsage
Code:
Copy      Help
;/
function# pid

;Returns process memory usage, KB.
;It is what you see in Task Manager, "Commit Size" column. Or in Process Hacker, "Private bytes" column.

;pid - process id. See <help>ProcessNameToId</help>, <google>GetWindowThreadProcessId</google>.


__Handle hp=OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION|PROCESS_VM_READ 0 pid)
if(hp=0) end ES_FAILED 16

PROCESS_MEMORY_COUNTERS z.cb=sizeof(z)
if GetProcessMemoryInfo(hp &z sizeof(z))
,ret z.PagefileUsage/1024
#7
This works for most processes, however for a process like iexplore.exe, I am only able to get the pid of "iexplore.exe", not "iexplore.exe *32".
 Using "int iexplore=ProcessNameToId("iexplore.exe *32" 0 1)" returns 0.
 Since iexplore.exe and iexplore.exe *32 have different PID assigned, how can I choose or select which to grab the memory for??

 ------------------------------------------------------------------------------------------------------------------
function# pid

pid=ProcessNameToId("iexplore.exe" 0 2)
;Returns process memory usage, KB.
;It is what you see in Task Manager, "Commit Size" column. Or in Process Hacker, "Private bytes" column.
;pid - process id. See <help>ProcessNameToId</help>.

__Handle hp=OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION|PROCESS_VM_READ 0 pid)
if(hp=0)
    end ES_FAILED 16

PROCESS_MEMORY_COUNTERS z.cb=sizeof(z)
if GetProcessMemoryInfo(hp &z sizeof(z))
    int ee = z.PagefileUsage/1024
    out pid
    out ee

 ------------------------------------------------------------------------------------------------------------------

Rob
#8
memory of current tab process
Macro Macro366
Code:
Copy      Help
int w=win("- Internet Explorer" "IEFrame")
int c=child("" "Internet Explorer_Server" w)

int pid; GetWindowThreadProcessId(c &pid)
out GetProcessMemoryUsage(pid)/1024.0

sum of memory of main window and all tab processes
Macro Macro366
Code:
Copy      Help
ARRAY(int) a
if(!ProcessNameToId("iexplore.exe" a)) ret
long mem
int i
for i 0 a.len
,mem+GetProcessMemoryUsage(a[i])
out mem/1024.0
#9
Nice, thx.  Just had time to check the thread and see your way is way better what I came up with.  Was able to accomplish the task adding in
 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 g2
GetProcessExename xpid processname "iexplore.exe"

if processname = "iexplore"
    pid = xpid
    goto findmemory
xpid = xpid + 1
if xpid = 11000
    end
goto g2
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
going through all pid names to find a match but know looping isnt ideal. 

Thanks for the code, have time now to play with it.  LMK if you have a donate button, really appreciate all the help.

Rob


Forum Jump:


Users browsing this thread: 1 Guest(s)