Skip to content

V8 memory leak? #17236

Answered by 0f-0b
guest271314 asked this question in Q&A
Dec 31, 2022 · 2 comments · 13 replies
Discussion options

You must be logged in to vote

It fails when receiving the second message because Deno.stdin.read(buffer) is not guaranteed to read exactly buffer.byteLength bytes, and thus the first message was not fully read. BufReader from std provides a convenient way to ensure that the whole buffer is filled.

import { BufReader } from "https://deno.land/std@0.170.0/io/buf_reader.ts";
import { BufWriter } from "https://deno.land/std@0.170.0/io/buf_writer.ts";

const stdin = new BufReader(Deno.stdin);
const stdout = new BufWriter(Deno.stdout);

async function getMessage() {
  const header = new Uint32Array(1);
  await stdin.readFull(new Uint8Array(header.buffer));
  const message = new Uint8Array(header[0]);
  await stdin.readFull(m…

Replies: 2 comments 13 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
13 replies
@guest271314
Comment options

@guest271314
Comment options

@0f-0b
Comment options

@guest271314
Comment options

@guest271314
Comment options

Answer selected by guest271314
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants