Cant put system in hibernation while firefox opened

I recently installed this system and sometimes when it should hibernate it ether come back to lock screen or get stuck with black screen and making laptop really hot (usually second variant happened overnight). I managed to recreate this issue with firefox opened, it doesn’t matter how many tabs are open. Journal says it Cannot allocate memory. I have 7 gigs of ram and 25 of swap. Could somebody please help me with this issue i dont really know what logs might be needed so i attach terminal outputs of status systemd-hibernate, please tell me if any other logs would be useful.

Failed hibernation, with firefox window opened in which there are singular new tab:

blitzcringe@trusty-hardware:~ » systemctl hibernate
blitzcringe@trusty-hardware:~ » systemctl status systemd-hibernate
× systemd-hibernate.service - System Hibernate
    Loaded: loaded (/usr/lib/systemd/system/systemd-hibernate.service; static)
    Active: failed (Result: exit-code) since Thu 2025-10-30 21:49:39 +04; 8s ago
Invocation: 8156974788dc4c579eb3bba9a533676c
      Docs: man:systemd-hibernate.service(8)
   Process: 13144 ExecStart=/usr/lib/systemd/systemd-sleep hibernate (code=exited, status=1/FAILURE)
  Main PID: 13144 (code=exited, status=1/FAILURE)
  Mem peak: 2M
       CPU: 2.342s

Oct 30 21:49:27 trusty-hardware systemd[1]: Starting System Hibernate...
Oct 30 21:49:27 trusty-hardware systemd-sleep[13144]: Successfully froze unit 'user.slice'.
Oct 30 21:49:28 trusty-hardware systemd-sleep[13144]: Performing sleep operation 'hibernate'...
Oct 30 21:49:39 trusty-hardware systemd-sleep[13144]: Failed to put system to sleep. System resumed again: Cannot allocate memory
Oct 30 21:49:39 trusty-hardware systemd-sleep[13144]: Successfully thawed unit 'user.slice'.
Oct 30 21:49:39 trusty-hardware systemd[1]: systemd-hibernate.service: Main process exited, code=exited, status=1/FAILURE
Oct 30 21:49:39 trusty-hardware systemd[1]: systemd-hibernate.service: Failed with result 'exit-code'.
Oct 30 21:49:39 trusty-hardware systemd[1]: Failed to start System Hibernate.
Oct 30 21:49:39 trusty-hardware systemd[1]: systemd-hibernate.service: Consumed 2.342s CPU time, 2M memory peak.

Successful hibernation, after closing firefox:

blitzcringe@trusty-hardware:~ » systemctl hibernate 
blitzcringe@trusty-hardware:~ » systemctl status systemd-hibernate
○ systemd-hibernate.service - System Hibernate
    Loaded: loaded (/usr/lib/systemd/system/systemd-hibernate.service; static)
    Active: inactive (dead)
      Docs: man:systemd-hibernate.service(8)

Oct 30 21:49:39 trusty-hardware systemd[1]: Failed to start System Hibernate.
Oct 30 21:49:39 trusty-hardware systemd[1]: systemd-hibernate.service: Consumed 2.342s CPU time, 2M memory peak.
Oct 30 21:49:57 trusty-hardware systemd[1]: Starting System Hibernate...
Oct 30 21:49:57 trusty-hardware systemd-sleep[13537]: Successfully froze unit 'user.slice'.
Oct 30 21:49:57 trusty-hardware systemd-sleep[13537]: Performing sleep operation 'hibernate'...
Oct 30 21:51:03 trusty-hardware systemd-sleep[13537]: System returned from sleep operation 'hibernate'.
Oct 30 21:51:03 trusty-hardware systemd-sleep[13537]: Successfully thawed unit 'user.slice'.
Oct 30 21:51:03 trusty-hardware systemd[1]: systemd-hibernate.service: Deactivated successfully.
Oct 30 21:51:03 trusty-hardware systemd[1]: Finished System Hibernate.
Oct 30 21:51:03 trusty-hardware systemd[1]: systemd-hibernate.service: Consumed 2.535s CPU time, 2M memory peak, 512K memory swap peak.

Can you post a free -h for when it fails?

Thanks for responding! Here you go.

blitzcringe@trusty-hardware:~ » systemctl hibernate                                                  
blitzcringe@trusty-hardware:~ » free -h
               total        used        free      shared  buff/cache   available
Mem:           6.7Gi       3.3Gi       2.7Gi       577Mi       1.4Gi       3.4Gi
Swap:           24Gi       3.6Gi        21Gi

The hint is Failed to put system to sleep. System resumed again: Cannot allocate memory so the system has trouble creating the hibernation image in memory, and apparently closing firefox frees enough space (probably a few hundred MB).

But alas I’m lost what could be done about it, never had that issue.