Voted #prosody by @prosodyim. Make sure to stay with the default backend, i.e. filestore, because it's stable and battle-tested.
I assume, that #ejabbberd by @ejabberd can also work with 4 GiB RAM. In that case, I recommend the PostgreSQL backend, not Mnesia.
Never tried to run a Matrix server. I only use it from #Jabber via the #slidge gateway.