Monday
18
Jun 2007

dlua GC API done

(5:29 pm) Tags: [Software, Projects, D Programming Language]

Just finished the GC API for the OO wrapper of dlua. I think the OO paradigm is really starting to show well.

An example:

import lua.wrap.lua;

import tango.io.Console;
import tango.io.Stdout;

void main()
{
Lua lua = new Lua();
Stdout.formatln (”init:\t{} bytes of memory”, lua.gc.memoryBytesUsed);
lua.execute(”print(’Hello World!’)”);
Stdout.formatln (”pre-gc:\t{} bytes of memory”, lua.gc.memoryBytesUsed);
lua.gc.stop();
lua.gc.restart();
Stdout.formatln (”start:\t{} bytes of memory”, lua.gc.memoryBytesUsed);
lua.gc.full();
Stdout.formatln (”post:\t{} bytes of memory”, lua.gc.memoryBytesUsed);
}

Output from that program on my Windows machine:

D:\d\dlua\examples\wrap>GCExample
init: 19254 bytes of memory
Hello World!
pre-gc: 19577 bytes of memory
start: 19577 bytes of memory
post: 19093 bytes of memory

As you can see, Lua is fairly memory efficient, and also code efficient, weighing in at about 30K of overhead compared to a basic “Hello World” D application, 132K vs 162K. To be fair, including Lua also means you are distributing a 132K DLL for the real Lua functionality.

Lua is a good fit for the D Programming Language, as shown here.

Popularity: 22%

Comments: (0)