The error message could be misleading. In fact, you may see another HINT message in the log,
portal_portaldb-slave.1.xxx | HINT: If this has occurred more than once some data might be corrupted and you might need to choose an earlier recovery target.
For portal 4.2, the memory limit of portaldb containers are set as the same as the RAM of docker host. ie. as soon as docker host still has free memory, the "invalid memory" message is more likely due to the corrupted data. In that case, we may need to restore the database with previous backup.
For more details about backup/restore, please refer to,
Here are some commands may be helpful on trouble shooing,
1. check memeory usage
docker stats --no-stream
2. export portaldb logs
1). docker service logs portal_portaldb-slave > portal_portaldb-slave.log 2>&1
2). docker service logs portal_portaldb > portal_portaldb.log 2>&1