Re: fps and Foreign(Obj/Ptr)

Malcolm Wallace <[email protected]> Wed, 5 Nov 2008 11:19:29 +0000
Newsgroups gmane.comp.lang.haskell.nhc.user
Organization Dept of Computer Science, University of York
Message-ID <[email protected]>
"Donn Cave" <[email protected]> wrote:

> I've run into a problem where it looks like my application crashes
> with "Error: allocation limit (1024) exceeded for Foreign(Obj/Ptr)"
> because it's using too many ByteStrings.  Does that seem plausible?

Yes, it seems plausible.  nhc98's runtime system has a constant-size
table for storing ForeignPtrs.

> Can I simply increase the size of that foreign[] array, by several
> orders of magnitude, to get around this?

Yes, but you will need to recompile nhc98's RTS.  (Not hard.) In
src/runtime/Kernel/cdata.c, just change the #define'd constant
MAX_FOREIGNOBJ, and then (at the toplevel)
    make runtime
    make install

*However*, you should also be aware that ByteStrings have been optimised
for use in ghc, not nhc98.  In fact, it turns out that using ByteString
is orders of magnitude slower than using plain String, in nhc98.  I
can't remember the exact factor, but it was something of the order of
60x slower.

Regards,
    Malcolm