One of my laptops is the identical model as yours, L502x. Your laptop is 11 years old.  The thermal compound has dried out and is not adequately transferring heat away from the processor, and there may be a lot of dust inside the laptop and maybe inside the fan and heat fins. So, your laptop is unable to adequately cool itself. Perform an internal cleaning. Open it up to clean out dust. Disassemble the fan to clean out dust and fluff. I found a fair bit in two laptops I worked on recently. Remove the heat sink, remove the old thermal compound and apply new thermal compound before reinstalling the heat sink. While you're in there, replace the CMOS battery. If it isn't dead, it soon will be. BIOS settings and date/time can't be saved without a functioning CMOS battery. You didn't say whether it has a hard drive or an SSD. If it's a hard drive, replacing it with an SSD will make it much faster and more responsive, a noticeable difference. You can get a Crucial Mx500 1TB SSD for less than$100 Canadian.  . To open the laptop remove/replace parts, follow the steps in Dell's service manual:XPS 15 L502X Service Manual (dell.com)There are good YouTube videos showing how to do the steps. If you don't find them, let me know and I can provide links. Whenever touching components or working inside a computer, wear a grounded wrist strap, also called anti-static wrist strap, ESD wrist strap, or ground bracelet. I know many people do such work without this, but it's a cheap and sensible precaution. You might also want to do what I did:I took a strip of lumber, about 3.5 cm. wide x 2 cm. high (1.5" x 3/4"}, and the length equal to the width of my laptop. I routed out two notches to accommodate the laptop's rear feet. The rear of the laptop sits in those notches, propping up the rear by 2 cm. That provides better ventilation underneath the laptop and makes it easier for the fan to draw in air via the bottom vent. 
Everytime I try to play minecraft on my XPS 15 L502X it violently overheats to the point where the keys start to warp. Do you think I should lower the graphic settings or just get better laptop. Thanks
My dell Laptop keeps overheating!!!