Firefox / i915 excessive RAM use?

Hi,
I’ve been running into OOM situations pretty frequently, sometimes even shortly after a fresh system boot.
The issue seems to go away if I don’t use Firefox so I tried to trace it down as much as my limited knowledge of linux memory management allowed.

The TLDR of it is that each open Firefox windows seems to increase Shmem use by ~300 MB so opening 50 Windows (even with just the default new tab open in each) increases Shmem use by ~17 GB. The memory use seems related to GEM objects on the integrated intel GPU (i7-13700H).

This is after starting Firefox with just one window:

free -h
               total        used        free      shared  buff/cache   available
Mem:            62Gi       2,9Gi        58Gi       1,3Gi       2,6Gi        59Gi
Swap:          511Mi          0B       511Mi

10 windows:

               total        used        free      shared  buff/cache   available
Mem:            62Gi       6,2Gi        55Gi       4,4Gi       5,7Gi        56Gi
Swap:          511Mi          0B       511Mi

50 windows:

               total        used        free      shared  buff/cache   available
Mem:            62Gi        21Gi        40Gi        18Gi        20Gi        41Gi
Swap:          511Mi          0B       511Mi

It seems that the shared memory use closely matches whats reported in i915_gem_objects:

cat /sys/kernel/debug/dri/1/i915_gem_objects
2501 shrinkable [0 free] objects, 18515492864 bytes
system: total:0x0000000fa293c000 bytes
stolen-system: total:0x0000000003c00000 bytes

Here is `/proc/meminfo’:

MemTotal:       65578224 kB
MemFree:        38245436 kB
MemAvailable:   38985832 kB
Buffers:           55980 kB
Cached:         25098988 kB
SwapCached:            0 kB
Active:          4045500 kB
Inactive:         545412 kB
Active(anon):    3287360 kB
Inactive(anon):        0 kB
Active(file):     758140 kB
Inactive(file):   545412 kB
Unevictable:    22206820 kB
Mlocked:              16 kB
SwapTotal:        524284 kB
SwapFree:         524284 kB
Zswap:                 0 kB
Zswapped:              0 kB
Dirty:              1160 kB
Writeback:             0 kB
AnonPages:       1641240 kB
Mapped:          2002376 kB
Shmem:          23851396 kB
KReclaimable:      68172 kB
Slab:             205400 kB
SReclaimable:      68172 kB
SUnreclaim:       137228 kB
KernelStack:       16800 kB
PageTables:        31504 kB
SecPageTables:         0 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    33313396 kB
Committed_AS:   29633132 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       83912 kB
VmallocChunk:          0 kB
Percpu:            16560 kB
HardwareCorrupted:     0 kB
AnonHugePages:    192512 kB
ShmemHugePages: 22132736 kB
ShmemPmdMapped:        0 kB
FileHugePages:    294912 kB
FilePmdMapped:     36864 kB
CmaTotal:              0 kB
CmaFree:               0 kB
Unaccepted:            0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:               0 kB
DirectMap4k:      203124 kB
DirectMap2M:     5820416 kB
DirectMap1G:    61865984 kB

Disabling HW acceleration in firefox roughly halfs the memory use but also seems to degrade performance.

Obviously the example above still leaves the system with enough RAM, but normally I’m running multiple VMs using about half of my available memory and its not uncommon for me to have more than 50 FF windows open …

Is that expected behavior? ~300 MB per window without any additional tabs seems excessive, especially since the memory doesn’t seem to be able to be swapped out.
Is anyone else seeing this behavior on their system (intel or other GPUs)?
Any advice on how to improve this other than disabling HW acceleration or cutting down on open FF windows?

I’d be grateful for any input.