Repository navigation
Closed
Labels
bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.
Description
Bug description
We observe significant memory consumption increase after migration from Prisma 6 to Prisma 7 for Postgres.
Severity
🚨 Critical: Data loss, app crash, security issue
Reproduction
Following example can be considered:
generator client {
provider = "prisma-client"
output = "../src/generated/prisma"
}
datasource db {
provider = "postgresql"
url = env("PRISMA_TEST_POSTGRES_URL")
}
model Sample {
time DateTime
sensorId String
pressure Float
temperature Float
@@unique([time, sensorId])
@@index([time])
}
The test script performing following steps:
- generate batch of data
- insert batch into database (Postgres)
- log memory usage
- repeat steps 1-3
import 'dotenv/config';
import { PrismaClient, type Sample } from './generated/prisma/client';
import { StatsWriter } from './stats-writer';
const DB_URL = process.env['PRISMA_TEST_POSTGRES_URL'];
const NUM_ITERATIONS = 1_000;
const BATCH_SIZE = 10_000;
const STATS_FILE = 'prisma-6.csv';
const stats = new StatsWriter(STATS_FILE);
const prisma = new PrismaClient({
datasourceUrl: DB_URL,
});
// in case of Prisma 7
//const prisma = new PrismaClient({
// adapter: new PrismaPg({ connectionString: DB_URL }),
//});
const nextBatch = (iteration: number, batchSize: number): Sample[] => {
return Array.from({ length: batchSize }, (_, i) => ({
time: new Date(iteration * batchSize + i),
sensorId: Math.random().toString(36).substring(2, 15),
pressure: Math.random() * 1000,
temperature: Math.random() * 10,
}));
};
const runTest = async () => {
await prisma.sample.deleteMany();
for (let i = 0; i < NUM_ITERATIONS; i++) {
const batch = nextBatch(i, BATCH_SIZE);
const start = process.hrtime.bigint();
await prisma.sample.createMany({ data: batch });
const end = process.hrtime.bigint();
const executionTimeMillis = Number(end - start) / 1_000_000;
await stats.write({
iteration: i,
executionTimeMillis,
memory: process.memoryUsage(),
});
}
};
await runTest();Expected vs. Actual Behavior
With the test script executed with Prisma 6 and Prisma 7 following results obtained:
Visual charts:
In our production workload, we have "bigger" data model (approx 40 attributes) and have NodeJS OOM crash in case of intensive data ingestion.
Frequency
Consistently reproducible
Does this occur in development or production?
Only in production (e.g., query engine, generated client)
Is this a regression?
Workaround
Prisma Schema & Queries
generator client {
provider = "prisma-client"
output = "../src/generated/prisma"
}
datasource db {
provider = "postgresql"
url = env("PRISMA_TEST_POSTGRES_URL")
}
model Sample {
time DateTime
sensorId String
pressure Float
temperature Float
@@unique([time, sensorId])
@@index([time])
}
const runTest = async () => {
await prisma.sample.deleteMany();
for (let i = 0; i < NUM_ITERATIONS; i++) {
const batch = nextBatch(i, BATCH_SIZE);
const start = process.hrtime.bigint();
await prisma.sample.createMany({ data: batch });
const end = process.hrtime.bigint();
const executionTimeMillis = Number(end - start) / 1_000_000;
await stats.write({
iteration: i,
executionTimeMillis,
memory: process.memoryUsage(),
});
}
};Prisma Config
import 'dotenv/config';
import { defineConfig } from 'prisma/config';
export default defineConfig({
schema: 'prisma/schema.prisma',
migrations: {
path: 'prisma/migrations',
},
});Logs & Debug Info
// Debug logs here
Environment & Setup
- OS: macOS, Linux
- Database: PostgreSQL
- Node.js version: v24.14.0
Prisma Version
7.4.2
Reacted by Simon Gheeraert, aiprojectchiwa, Dmitriy Solokhin, Stanislav (Stanley) Modrak, Hellen Cristina, Elisha Hung, Rythelle, saroro, Nikolay Siniakevich, Lo Ditzz and 4 more
Metadata
Metadata
Assignees
Labels
bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.
Activity
idirdev commentedon Mar 11, 2026
This is a significant regression. Going from ~580MB (Prisma 6) to ~780MB (Prisma 7) on the same workload is a ~35% increase that really matters in containerized environments with tight memory limits.
A few things worth checking:
Prisma 7 uses a different client engine (prisma-client generator vs the old prisma-client-js). The new engine might be keeping more internal state per query or not releasing query result buffers as aggressively.
Your test inserts 10,000 rows per iteration. If Prisma 7 serializes the entire batch differently (e.g. keeping a copy of the input data alongside the query plan), that would explain the linear memory growth.
The memory chart might show V8 heap growth rather than actual unreclaimable memory. You could try forcing GC between iterations to check:
If memory drops significantly after gc(), its just GC not running often enough. If it stays high, theres a genuine leak.
As a workaround, try batching the inserts in smaller chunks (1000 instead of 10000). Smaller batches put less pressure on the serialization/buffering path.
alexander-eroma commentedon Mar 13, 2026
Hello all.
Regarding the explicit GC call, for sure it improves the memory consumption and can be considered as a dev env workaround but not prod level solution.
Also, Prisma 7.5 have been released recently, so i've also included it into charts:
Average values:
bgc-hellen commentedon Mar 18, 2026
I am facing the exact same issue in Prisma version 7.5
rythelle commentedon Mar 19, 2026
I have the same problem
solokhind commentedon Mar 20, 2026
Seeing the same behavior in v7.5. In my case, memory usage continuously increases over time without stabilizing, eventually reaching ~2GB and exhausting the server. Downgrading to v6 resolves the issue.
knzt commentedon Mar 20, 2026
Same problem here! also in v7.5
shakim commentedon Mar 22, 2026
Same issue.
I have also noticed that each call to createMany generates a cache miss even though the row structure stays the same (no undefined or null values)
Memory usage increases indefinitely to the point of crashing the process.
Environment:
sdebaene commentedon Mar 23, 2026
Same issue here. My app is crashing non stop.
bgc-carlos-henrique commentedon Mar 23, 2026
Same issue here!
fix(client): prevent caching of createMany queries to avoid cache blo…
fix(client): prevent caching of createMany queries to avoid cache blo…
khalidsaidi commentedon Mar 25, 2026
A2ABench has an accepted answer for this imported thread.
ai village