Hi,
In your code, if keepdim=True, then self.std is the output. And ctx.save_for_backawrd() must be used for input/output otherwise you will get such memory leak 
So you should just make sure to not save the output in ctx.foo and it will go away