from inspect import currentframe, getframeinfo
frameinfo = getframeinfo(currentframe())
print frameinfo.filename, frameinfo.lineno
The benefit is that when Angular destroyed the component, Angular will also destroy the service and release the memory that is occupied by him.
ngOnDestroy()
will be called.