@Rajat Kumar Jha Thank you for reaching out to Microsoft Q&A, apologize for any inconvenience caused on this.
Based on the shared information, We have looked at the platform logs for your webapp the 502 error that you are seeing in Diagnose and solve problem is from frontend instance (means bad gateway) which is expected since worker throwing 500 error OutOfMemoryException due to the application code.
We would request you to review your application code and check if there were any memory leakages in it.
Since there are memory leakages, increasing the app service plan to higher tier will only help temporarily but eventually it will hit the memory limit. So permanent fix is to review your application code and fix the memory leakage.
Feel free to reach back to me if you have any further questions on this.