OS: Windows.
I wrote a DLL which itself uses the Ruby (1.6.8) DLL.
My DLL creates some objects, loads a script, calls some functions in the
script and destroys the object again. Should be neutral to memory
consumption. When I issue “ObjectSpace.each_object(Object) {}”, I always get
the same value (±5 objects). I call the GC regularly.
Problem is, that when I do that procedure (create an object, call the script
functions) multiple times, that the “VM Size” of the process increases more
and more.
Background: my DLL is a plugin for the spam fighting tool “SpamPal”, and I
use Ruby to process the mails. I create a "CMail’ object, and for each mail
I create an instance and call the spam-testing functions. And when I have
filtered about 1000 mails, VM Size has grown to 400 MB and the computer runs
out of virtual memory and crashes.
Is there a problem known, or any way to find the cause?
I would call myself an experienced programmer and I am pretty sure that the
memory is NOT used by my DLL, but from the Ruby DLL (which is more or less a
black box for me).
I create objects using:
VALUE vMail = RUBYFUNC(rb_define_class)(“CMail”,*RUBYFUNC(rb_cObject));
RUBYFUNC(rb_define_singleton_method)(vMail,“new”,RB_METHOD(clsMail::alloc),0
);
… define some methods
_vMail = _Ruby.Call(vMail, RUBYFUNC(rb_intern)(“new”), 0);
RUBYFUNC(rb_gc_register_address)(&_vMail);
and release them by
RUBYFUNC(rb_gc_unregister_address)(&_vMail);
I would assume that to allow the GC to destroy the objects afterwards,
correct? Wouldn’t the “ObjectSpace.each_object(Object) {}” increase if I
were leaking objects?
Thanks for any help I can get!
Christian