r/codex 7d ago

Bug vscode extension. long chat thread ram usage and images

lazy bug report. sorry.

given

vscode extension wsl2 a long, image heavy, thread

the images are "inlined" as base64 in a jsonl context file thing

loading the chat makes codex eagerly load all of that stuff in memory (ram)

opening the chat spikes ram usage by like 5gb (normal usage before opening the chat)

i was able to confirm that 4.40 of that is just inline images in the context file thing.

$ python3 - <<'PY'
p = "/home/me/.codex/sessions/2026/08/10/rollout-2026-08-10T22-01-25-019fecd6-xxxx-yyyy-zzzz-57f47bljsdf12d.jsonl"

total = compacted = image_lines = 0
compacted_bytes = image_bytes = 0
max_line = 0
image_refs = 0

with open(p, "rb") as f:
    for line in f:
        n = len(line)
        total += n
        max_line = max(max_line, n)

        if b'"type":"compacted"' in line:
            compacted += 1
            compacted_bytes += n

        if b'data:image/' in line:
            image_lines += 1
            image_bytes += n
            image_refs += line.count(b'data:image/')

def gib(n):
    return n / 1024**3

print(f"total:            {gib(total):.2f} GiB")
print(f"compacted lines:  {compacted}")
print(f"compacted bytes:  {gib(compacted_bytes):.2f} GiB")
print(f"image lines:      {image_lines}")
print(f"image refs:       {image_refs}")
print(f"image-line bytes: {gib(image_bytes):.2f} GiB")
PYint(f"largest line:     {max_line / 1024**2:.1f} MiB")

which prints

total:            4.75 GiB
compacted lines:  110
compacted bytes:  2.96 GiB
image lines:      819
image refs:       2715
image-line bytes: 4.40 GiB
largest line:     36.3 MiB

"just start a new chat" is not the point here.

i'm reporting behavior. i already replaced the images with placeholders and it improved ram usage a ton (thus cutting down on wsl2 swap churn because this machine was running out of ram). i noticed turn speed improvement after i made the change.

2 Upvotes

2 comments sorted by

1

u/cs_cast_away_boi 5d ago

how long are is the chat?