title: Controlling Lua5.1's garbage collector
body: <p>OK so I have a C++ class that is exposed to Lua using SWIG. The script creates the object but a manager class also has a pointer to the object so it can be modified in C++(or another script) for whatever reason.</p>
  
  <p>The problem is that when the script finishes the object is freed, how can I control what the Garbage collector collects without having to implement a gc metamethod?</p>
  
  <p>Here is an example:</p>
  
  <pre><code>--Script that creates the object
  someObject = Utils.Object("Obj name");
  </code></pre>
  
  <p>Now the Object has registered itself with the manager so the rest of the application(and other scripts) can access it.</p>
  
  <pre><code>--Another script
  obj = ObjManager:GetObject(0);
  </code></pre>
  
  <p>Clearly not a very realistic example but hopefully it illustrates my question. Is there a way to veto the garbage collector without a gc metamethod in C++?</p>
  
  <p>Just to clarify the manager is in C++, and Utils is the module name housing the exposed class. Also the object registers itself to the manager in its constructor.</p>
  
  <p>Thanks in advance.</p>