1:50 PM PT -- TMZ has learned Ralphie died at a private residence in Vegas Friday morning. We're told he had been battling pneumonia for 6 weeks and died of cardiac arrest. According to his rep, someone in the residence discovered his body.

He had performed Thursday night at Harrah's in Vegas.

Comedian Ralphie May died Friday at the age of 45 ... TMZ has learned.

Ralphie had been battling pneumonia over the last week, but kept performing his scheduled gigs in Las Vegas.

Ralphie's stand-up comedy career took off after he finished second on "Last Comic Standing" in 2003. Since then he's had several televised comedy specials -- mostly on Netflix and Comedy Central -- and he's continued touring, almost nonstop, around the country.

His manager, Judi Marmel, tells us, "As his manager and his friend, I will miss his laugh, his generosity to fellow comedians, his trademark orneriness, and his enormous love of life. He left us entirely too soon -- and we can only wonder where his comedy might have taken all of us. We send our love to his family, his fans, and all the comics who shared stages with him across the country."

In 2015 he and his wife Lahna Turner, also a comedian, filed for divorce. Ralphie was devastated by the split and the ensuing custody battle over their 2 kids, April June May and August James May.