A father-of-one caught with heroin after gardai raided his home was "in the throes of an addiction" at the time, a court heard.
Shane Fowler (30) was buying in bulk and smoking the drug with a friend.
Judge David McHugh imposed an eight-month sentence but suspended it for two years.
The defendant admitted before Blanchardstown District Court to possession of heroin as well as having the drug for sale or supply.
Sergeant Maria Callaghan said gardai obtained a warrant and searched a house at Dunsink Drive in Finglas on October 22, 2014.
Sgt Callaghan said that, during the course of the search, heroin with a street value of €635 was found.
The court heard that the defendant had 44 previous convictions, mostly for road traffic matters.
Defence lawyer Jennifer Jackson said the defendant's parents were both heroin addicts and he was surrounded by drugs as a child, with local users assembling at their home.
Ms Jackson said it was incredible that, given his upbringing, Fowler did not have previous drug convictions.
She also said he was in the throes of an addiction at the time of this incident.
Ms Jackson added he is now clean and working with probation services.