Updated

An actor who appeared in "The 40-Year-Old Virgin" has been arrested for investigation of attempted murder after his former girlfriend was stabbed more than 20 times, leaving her critically injured, authorities said Tuesday.

Shelley Malil, 43, remained in custody on $2 million bail after he was taken into custody late Monday as he left a train in Oceanside, California, the San Diego County Sheriff's Department said. His arraignment is scheduled for Wednesday.

Authorities did not know the condition of his girlfriend, whose name was not released. She was in critical condition Monday.

Click here for photos, more information on Malil

Deputies found the victim Sunday night while responding to reports of screams for help and breaking glass in San Marcos, about 15 miles (24 kilometers) east of Oceanside.

"Malil and the victim had apparently been in a dating relationship which recently ended," the sheriff's department said in a statement.

Malil, who lives in Sherman Oaks, a suburb of Los Angeles, was arrested for investigation of attempted murder, mayhem and burglary and booked into the county's Vista Detention Center, the statement said.

He had taken the train from Los Angeles to meet his attorney, who had joined the actor's family and friends in persuading him to turn himself in, deputies said.

Attempts to identify and reach his attorney for comment were unsuccessful.

Malil played one of star Steve Carell's co-workers in "The 40-Year-Old-Virgin" and has appeared in dozens of TV shows including "NYPD Blue" and "Scrubs."