Having the weak ref on the same object requires to split object destruction (which needs to happen in last strong ref release) from memory deallocation (which needs to happen in last weak ref release), but I think it should work otherwise (with this fix for the double free).