Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
299e50cbf7 | |||
1e6af24df0 |
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@pushrocks/smartmetrics",
|
||||
"version": "2.0.2",
|
||||
"version": "2.0.3",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@pushrocks/smartmetrics",
|
||||
"version": "2.0.2",
|
||||
"version": "2.0.3",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@pushrocks/smartdelay": "^2.0.13",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartmetrics",
|
||||
"version": "2.0.2",
|
||||
"version": "2.0.3",
|
||||
"private": false,
|
||||
"description": "easy system metrics",
|
||||
"main": "dist_ts/index.js",
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/smartmetrics',
|
||||
version: '2.0.2',
|
||||
version: '2.0.3',
|
||||
description: 'easy system metrics'
|
||||
}
|
||||
|
@ -34,8 +34,10 @@ export class SmartMetrics {
|
||||
// Ignore - this will fail if not running in a Docker container
|
||||
}
|
||||
|
||||
this.maxMemoryMB = Math.min(totalSystemMemoryMB, dockerMemoryLimitMB);
|
||||
|
||||
// Set the maximum memory to the lower value between the Docker limit and the total system memory
|
||||
this.maxMemoryMB = Math.min(totalSystemMemoryMB, dockerMemoryLimitMB, maxHeapSizeMB);
|
||||
|
||||
// If the maximum old space size limit is greater than the maximum available memory, throw an error
|
||||
if (maxHeapSizeMB > this.maxMemoryMB) {
|
||||
throw new Error('Node.js process can use more memory than is available');
|
||||
}
|
||||
@ -88,7 +90,6 @@ export class SmartMetrics {
|
||||
memoryUsageBytes += stats[stat].memory;
|
||||
}
|
||||
|
||||
// Correct memory usage percentage calculation
|
||||
let memoryPercentage = Math.round((memoryUsageBytes / (this.maxMemoryMB * 1024 * 1024)) * 100 * 100) / 100;
|
||||
let memoryUsageText = `${memoryPercentage}% | ${this.formatBytes(memoryUsageBytes)} / ${this.formatBytes(this.maxMemoryMB * 1024 * 1024)}`;
|
||||
|
||||
|
Reference in New Issue
Block a user