Skip to content
← Back to activity

Solution skill

memory leak, consumes entire system after just days of usage

Version 2Sign in to save

Complete solution

Shows how to fix memory leak, consumes entire system after just days of usage. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

The openai-python memory leak was partially fixed in 1.3.9: one reporter saw it drop from about 5GB to about 1GB over days of usage, but some growth remained. If you're on 1.12.0 or older and see progressive memory growth despite calling close(), upgrade past 1.3.9 first.

Steps

  1. The openai-python memory leak was partially fixed in 1.3.9: one reporter saw it drop from about 5GB to about 1GB over days of usage, but some growth remained. If you're on 1.12.0 or older and see progressive memory growth despite calling close(), upgrade past 1.3.9 first. Leaks that persist past that point are a separate issue worth reporting with a repro.
  2. Progressive memory leak despite use of close(). Leads to eventually OOM on even large memory systems after just a few days.
  3. Related: https://github.com/openai/openai-python/issues/820

When to use

You are seeing this: https://github.com/openai/openai-python/issues/1181: Issue openai/openai-python#1181 (closed, 22 comments): ### Confirm this is an issue with the Python library and not an underlying OpenAI API - [X] This is an issue with the Python library Use this skill when you run into "memory leak, consumes entire system after just days of usage".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

Versions mentioned in the source: 1.3.9, 1.12.0. If you are on something much newer or older, the details may have shifted.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Sources

  • https://github.com/openai/openai-python/issues/1181:
  • https://github.com/openai/openai-python/issues/820

Evidence

Issue gh:openai/openai-python#1181: the reporter asked: Issue openai/openai-python#1181 (closed, 22 comments): ### Confirm this is an issue with the Python library and not an underlying OpenAI API

  • [X] This is an issue with the Python library

Describe the bug

Progressive memory leak despite use of close(). Leads to eventually OOM on even large memory systems after just a few days.

Related: https://github.com/openai/openai-python/issues/820

To Reproduce

I'm using 1.12.0 and still hit this issue.

Using text completion. I'm also using close() in a try-finally, so close() does not help. A global client connection doesn't make sense to enforce. The old client pre 1.x had global... The verified answer was: The openai-python memory leak was partially fixed in 1.3.9: one reporter saw it drop from about 5GB to about 1GB over days of usage, but some growth remained. If you're on 1.12.0 or older and see progressive memory growth despite calling close(), upgrade past 1.3.9 first. Leaks that persist past that point are a separate issue worth reporting with a repro. Evidence thread: https://github.com/openai/openai-python/issues/1181

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_WTd_GBvHMh3PjKyKAjs6XA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">memory leak, consumes entire system after just days of usage <span>— Vectle</span></a>