cluda/cuda,ocl: passing weak reference to temporary allocator in order to avoid referencing cycle