mirror of
https://github.com/CaramelFur/Picsur.git
synced 2026-05-06 18:37:24 +02:00
add some memory logging
This commit is contained in:
@@ -82,7 +82,6 @@ export class IngestService {
|
||||
},
|
||||
{
|
||||
jobId: uuidv4(),
|
||||
delay: 30000,
|
||||
},
|
||||
)) as ImageIngestJob;
|
||||
if (!job.id) return Fail(FT.Internal, undefined, 'Failed to queue job');
|
||||
|
||||
@@ -75,16 +75,6 @@ export class ImageController {
|
||||
params,
|
||||
),
|
||||
);
|
||||
|
||||
const isbfufer = image.data instanceof Buffer;
|
||||
console.log('isabuffer', isbfufer);
|
||||
if (!isbfufer) {
|
||||
console.log('not a buffer');
|
||||
console.log(image.data);
|
||||
|
||||
console.trace();
|
||||
process.exit();
|
||||
}
|
||||
|
||||
res.type(ThrowIfFailed(FileType2Mime(image.filetype)));
|
||||
return image.data;
|
||||
|
||||
@@ -11,6 +11,8 @@ import {
|
||||
import { UniversalSharpIn, UniversalSharpOut } from './universal-sharp';
|
||||
|
||||
export class SharpWorker {
|
||||
private maxMemoryUsed = 0;
|
||||
|
||||
private startTime: number = 0;
|
||||
private sharpi: Sharp | null = null;
|
||||
|
||||
@@ -36,6 +38,17 @@ export class SharpWorker {
|
||||
|
||||
process.on('message', this.messageHandler.bind(this));
|
||||
|
||||
process.nextTick(() => {
|
||||
let memUsage = process.memoryUsage();
|
||||
if (memUsage.rss > this.maxMemoryUsed) {
|
||||
this.maxMemoryUsed = memUsage.rss;
|
||||
}
|
||||
});
|
||||
|
||||
setInterval(() => {
|
||||
console.log(`Used ${JSON.stringify(process.memoryUsage())} bytes`);
|
||||
}, 100);
|
||||
|
||||
this.sendMessage({
|
||||
type: 'ready',
|
||||
});
|
||||
@@ -92,6 +105,10 @@ export class SharpWorker {
|
||||
const result = await UniversalSharpOut(sharpi, filetype, options);
|
||||
const processingTime = Date.now() - this.startTime;
|
||||
|
||||
console.log(
|
||||
`\nUsed ${this.maxMemoryUsed} bytes`,
|
||||
);
|
||||
|
||||
this.sendMessage({
|
||||
type: 'result',
|
||||
processingTime,
|
||||
|
||||
Reference in New Issue
Block a user