-
-
Notifications
You must be signed in to change notification settings - Fork 917
Open
Labels
Description
What version of Hono are you using?
4.11.3
What runtime/platform is your app running on? (with version if possible)
Bun v1.3.5
What steps can reproduce the bug?
Touch src/index.ts
import { Hono } from "hono";
const app = new Hono();
// test
const matrixMultiply = (size: number) => {
const a = Array.from({ length: size }, () =>
Array.from({ length: size }, () => Math.random())
);
const b = Array.from({ length: size }, () =>
Array.from({ length: size }, () => Math.random())
);
const m = a.length,
n = a[0].length,
p = b[0].length;
const result = Array.from({ length: m }, () => new Array(p).fill(0));
for (let i = 0; i < m; i++) {
for (let j = 0; j < p; j++) {
for (let k = 0; k < n; k++) {
result[i][j] += a[i][k] * b[k][j];
}
}
}
return result;
};
app.get("/dynamic/matrix", (c) => {
const size = 200;
const product = matrixMultiply(size);
return c.json({
result: `Matrix multiply (${size}x${size}) done. First element: ${product[0][0].toFixed(
4
)}`,
});
});
const server = Bun.serve({
port: 3000,
fetch: app.fetch,
});Build with docker
FROM oven/bun:alpine AS build
WORKDIR /work
COPY package.json bun.lock ./
RUN bun install
COPY ./src ./src
ENV NODE_ENV=production
RUN bun build \
--compile \
--minify-whitespace \
--minify-syntax \
--outfile app \
src/index.ts
# Runtime
FROM alpine
RUN apk add --no-cache libstdc++
WORKDIR /work
COPY --from=build /work/app app
ENV NODE_ENV=production
EXPOSE 3000
ENTRYPOINT ["./app"]And run docker build & docker run
test by wrk
wrk -c 500 -t 15s http://localhost:3000/dynamic/matrixWhat is the expected behavior?
Memory usage can be released
What do you see instead?
Use docker stats with wrk
- init memory: 5.43MB
- max memory: 78.25MB
- after 5 min memory: 46.86MB
- after 30 min memory: 46.86MB
Additional information
No response