You are allocating far too much
dbcache. If you allocate 4000 MB to the dbcache, you will use up all of your RAM and it will crash. Your operating system needs RAM, Bitcoin Core itself needs RAM outside of the dbcache. I would highly recommend that you do not set a dbcache at all as 4 GB is really not enough RAM to handle a larger dbcache, Bitcoin Core's other RAM usage, operating system RAM usage, and whatever else may be running on your machine.
I suggest that you start Bitcoin Core without dbcache and check what your RAM usage is (using
top or Ubuntu's system monitor). See how much RAM is being used and how much is free. Then you can set a higher dbcache if you have enough free.
Bitcoin Core has a few other suggestions for reducing memory usage. You can set
maxmempool=<n> to a number less than the default
300. You can reduce the maximum number of connections by setting
maxconnections=<n> to a number smaller than 125. Note that that only is helpful if you happen to have a lot of incoming connections. Lastly you can reduce the number of threads being used for signature validiation by using
par=<n> and setting it to a number smaller than the number of cores your CPU has.