mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-17 08:37:59 +00:00
perf: memory leak (#5370)
* perf: memory leak * perf: workflow share buffer;Circle checker;Get file from stream * doc * remove report.md
This commit is contained in:
@@ -20,5 +20,17 @@ export const readRawContentFromBuffer = (props: {
|
||||
encoding: string;
|
||||
buffer: Buffer;
|
||||
}) => {
|
||||
return runWorker<ReadFileResponse>(WorkerNameEnum.readFile, props);
|
||||
const bufferSize = props.buffer.length;
|
||||
|
||||
// 使用 SharedArrayBuffer,避免数据复制
|
||||
const sharedBuffer = new SharedArrayBuffer(bufferSize);
|
||||
const sharedArray = new Uint8Array(sharedBuffer);
|
||||
sharedArray.set(props.buffer);
|
||||
|
||||
return runWorker<ReadFileResponse>(WorkerNameEnum.readFile, {
|
||||
extension: props.extension,
|
||||
encoding: props.encoding,
|
||||
sharedBuffer: sharedBuffer,
|
||||
bufferSize: bufferSize
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user