mtasa-blue icon indicating copy to clipboard operation
mtasa-blue copied to clipboard

Add getProcessMemory function

Open samr46 opened this issue 4 years ago • 4 comments

Solves #1563

Adds getProcessMemory()

This function returns the current memory usage of gta_sa.exe process. Essentially copied from CMemStats.cpp (win api call) Returned value in KB is equal to the one displayed in memory stats ("showmemstat" command)

It will be useful for big servers that push memory boundaries to the limit (about 3.3 GB) to avoid crashing the client. It's not a secret that when you disconnect from one server and connect to another the current memory usage increases and increases (i personally saw values up to 1.6 GB usage after disconnect). So if you add let's say 1 GB of models to this and some other things the usage will get dangerously close to the limit right after the loading.

This function should allow servers to determine if current memory usage is not too high for their resources. And in this case server could use alternative (more optimized) loading mode or notify the user and ask to restart MTA. Also it could be used to monitor the memory during gameplay and notify the user if it's getting too high (so user could restart MTA before it unexpectedly crashes in a bad moment).

samr46 avatar Sep 22 '21 17:09 samr46

maybe it's better to add it to dxGetStatus?

Vadya963 avatar Sep 22 '21 18:09 Vadya963

maybe it's better to add it to dxGetStatus?

Maybe. I thought about this function in the first place since it has TotalPhysicalMemory now. But didn't feel good to use this win api call in dxGetStatus. I guess we need more feedback about this.

samr46 avatar Sep 22 '21 18:09 samr46

Add support for returning in bytes, that should be good.

jacuniadev avatar Oct 12 '21 15:10 jacuniadev

what is the progress of this?

Shuubaru avatar Dec 11 '21 18:12 Shuubaru

Superseded by commit dd571b4793ac6773c634a1cdc6b28bfa00891127

botder avatar Nov 01 '22 00:11 botder