Are you doing something in a loop? Are you spawning the constraint or the object when grabbing? Out of memory exception usually means that your process demanded more RAM or VRAM than is available, that usually happens if you have ALOT of objects in the scene, or a lot of variables. Or too little RAM/VRAM in your system