@crawlee/core
Version:
The scalable web crawling and scraping library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.
44 lines (43 loc) • 1.53 kB
TypeScript
import type { Log } from '@apify/log';
import type { Configuration } from '../configuration';
import type { LoadSignal, LoadSnapshot } from './load_signal';
import type { SystemInfo } from './system_status';
export interface MemorySnapshot extends LoadSnapshot {
usedBytes?: number;
}
export interface MemoryLoadSignalOptions {
maxUsedMemoryRatio?: number;
overloadedRatio?: number;
snapshotHistoryMillis?: number;
config: Configuration;
log?: Log;
}
/**
* Tracks memory usage via `SYSTEM_INFO` events and reports overload when
* the used-to-available memory ratio exceeds a threshold.
*/
export declare class MemoryLoadSignal implements LoadSignal {
readonly name = "memInfo";
readonly overloadedRatio: number;
private readonly store;
private readonly config;
private readonly events;
private readonly log;
private readonly maxUsedMemoryRatio;
private maxMemoryRatio;
private maxMemoryBytes;
private lastLoggedCriticalMemoryOverloadAt;
constructor(options: MemoryLoadSignalOptions);
start(): Promise<void>;
stop(): Promise<void>;
getSample(sampleDurationMillis?: number): MemorySnapshot[];
/**
* Returns typed memory snapshots for backward compatibility with `Snapshotter`.
*/
getMemorySnapshots(): MemorySnapshot[];
/** @internal */
_onSystemInfo(systemInfo: SystemInfo): void;
/** @internal */
_memoryOverloadWarning(systemInfo: SystemInfo, maxMemoryBytes?: number): void;
private _getTotalMemoryBytes;
}