Releasing variables

Is there any sort of protocol or method for releasing objects from a class once they’re not needed?

I wrote a class and included a release() function which changes all of the self variables to nil:

function Prime:init(x)
    -- you can accept and set parameters here
    print( "Prime:init()", x )
    self.x = x
    self.didFindCoprimes = false
    self.coprimes = {}
    self.primitives = {}

function Prime:release()
    self.x = nil
    self.coprimes = nil
    self.primitives = nil

I am using it in this context:

local i = 1
    for i = 1, 20 do 
        local p = Prime( i )
        if( p:findPrimitives() > 0 ) then
            print( "primitives for ", p.x..":" )
            tableIterator( p.primitives )

I don’t know if it works tho, releasing the memory. Is there any way to interact with the garbage collector and know if memory a variable was pointing to was released?

@matkatmusic to quote @John:
“Codea uses Lua and Lua uses garbage collection, so basically if an object becomes unreachable (there are no references to it or something that indirectly references it) then it is deleted. Garbage collection is expensive and so its only performed periodically, or when needed (low memory). If you nil a reference to a physics object it will hang around in Codea for a little while due to a delay in garbage collection. Destroy is called automatically when an object is garbage collected, but if you want it to be gone instantly, you need to call destroy manually before clearing references to your object.”

Edit: To find out how much memory is being held by the gc do something like:
mem = collectgarbage(“count”)/1024 (divide bytes in to kb)

That should display the memory count in the bottom left corner of the screen.