I agree with what @shubham recommended to increase memory to the container. A couple of things to also be mindful of:
- In your task definition, make sure the "Resource allocation limits" are in line with what your task memory limits are. Meaning, if you set your task memory to 6GB for example, but your limits are hard capped at 4GB, you will still receive this error
- Per this SO answer, you may want to also increase your ulimit memlock hard and soft limits (note this is in KB) or your nofile limits (though I doubt nofile is causing the issue). For example, if you set your task memory to have 6GB and expect your batch job to be close to this then you will want to increase your ulimit memlock (also in the task definition) to be 6GB (or 6291456, 1024 * 1024 * 6)