Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Adding memory usage warning with nbresuse#8437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
blink1073 merged 3 commits intojupyterlab:masterfromGsbreddy:master
May 18, 2020
Merged
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
Adding memory usage warning with nbresuse#8280
  • Loading branch information
Gottam Sai Bharath authoredMay 18, 2020
commite2b65070411e35afc43c89de4f5497015f20be26
25 changes: 22 additions & 3 deletionspackages/statusbar/src/defaults/memoryUsage.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,6 +13,8 @@ import { Poll } from '@lumino/polling';

import { TextItem } from '..';

import { nbresuse } from '../style/text';

/**
* A VDomRenderer for showing memory usage by a kernel.
*/
Expand DownExpand Up@@ -43,7 +45,11 @@ export class MemoryUsage extends VDomRenderer<MemoryUsage.Model> {
this.model.units
}`;
}
return <TextItem title="Current memory usage" source={text} />;
if (!this.model.usageWarning) {
return <TextItem title="Current memory usage" source={text} />;
} else {
return <TextItem title="Current memory usage" source={text} className={nbresuse} />;
}
}
}

Expand DownExpand Up@@ -119,6 +125,13 @@ export namespace MemoryUsage {
return this._units;
}

/**
* The warning for memory usage.
*/
get usageWarning(): boolean {
return this._warn;
}

/**
* Dispose of the memory usage model.
*/
Expand All@@ -137,32 +150,37 @@ export namespace MemoryUsage {
const oldCurrentMemory = this._currentMemory;
const oldMemoryLimit = this._memoryLimit;
const oldUnits = this._units;
const oldUsageWarning = this._warn;

if (value === null) {
this._metricsAvailable = false;
this._currentMemory = 0;
this._memoryLimit = null;
this._units = 'B';
this._warn = false;
} else {
const numBytes = value.rss;
const memoryLimit = value.limits.memory
? value.limits.memory.rss
: null;
const [currentMemory, units] = Private.convertToLargestUnit(numBytes);
const usageWarning = value.limits.memory.warn;

this._metricsAvailable = true;
this._currentMemory = currentMemory;
this._units = units;
this._memoryLimit = memoryLimit
? memoryLimit / Private.MEMORY_UNIT_LIMITS[units]
: null;
this._warn = usageWarning;
}

if (
this._currentMemory !== oldCurrentMemory ||
this._units !== oldUnits ||
this._memoryLimit !== oldMemoryLimit ||
this._metricsAvailable !== oldMetricsAvailable
this._metricsAvailable !== oldMetricsAvailable ||
this._warn !== oldUsageWarning
) {
this.stateChanged.emit(void 0);
}
Expand All@@ -173,6 +191,7 @@ export namespace MemoryUsage {
private _metricsAvailable: boolean = false;
private _poll: Poll<Private.IMetricRequestResult | null>;
private _units: MemoryUnit = 'B';
private _warn: boolean = false;
}

/**
Expand DownExpand Up@@ -271,7 +290,7 @@ namespace Private {
limits: {
memory?: {
rss: number;
warn?:number;
warn?:boolean;
};
};
}
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp