M
Mark Shelor
I'm the author of a CPAN module (Digest::SHA) that's implemented mostly
in C. A few of the underlying C routines use "malloc()" and "free()" to
create and destroy various data structures at runtime. So far, the CPAN
test results haven't indicated any big problems.
However, a user contacted me the other day with reports of "pool" errors
when attempting to build and run the Digest::SHA test scripts on MSWin.
He didn't have any specifics about the Perl implementation he was
using, but it wasn't ActiveState. He also stated that this particular
Perl implementation was reported to have problems, but again, he wasn't
specific.
So, with little else to go on, I began to suspect that there might be a
conflict between the memory manager in his Perl implementation, and the
memory management that's being done by the C library's malloc() and
free() functions.
So, my question: is it generally required (or recommended) to avoid
using malloc's within the C code of Perl extensions, and to instead use
Perl's memory management functions (e.g. New) within the XS code? Doing
this would cost me quite a bit of effort, so I'm reluctant to go ahead
with this approach, especially if it turns out not to have been the
problem in the first place.
Mark
in C. A few of the underlying C routines use "malloc()" and "free()" to
create and destroy various data structures at runtime. So far, the CPAN
test results haven't indicated any big problems.
However, a user contacted me the other day with reports of "pool" errors
when attempting to build and run the Digest::SHA test scripts on MSWin.
He didn't have any specifics about the Perl implementation he was
using, but it wasn't ActiveState. He also stated that this particular
Perl implementation was reported to have problems, but again, he wasn't
specific.
So, with little else to go on, I began to suspect that there might be a
conflict between the memory manager in his Perl implementation, and the
memory management that's being done by the C library's malloc() and
free() functions.
So, my question: is it generally required (or recommended) to avoid
using malloc's within the C code of Perl extensions, and to instead use
Perl's memory management functions (e.g. New) within the XS code? Doing
this would cost me quite a bit of effort, so I'm reluctant to go ahead
with this approach, especially if it turns out not to have been the
problem in the first place.
Mark