#2105: garbage collection confusing in ghci for foreign objects
-----------------------------------------+----------------------------------
Reporter: Frederik | Owner:
Type: run-time performance bug | Status: new
Priority: normal | Component: GHCi
Version: 6.8.2 | Severity: normal
Keywords: | Testcase:
Architecture: Unknown | Os: Unknown
-----------------------------------------+----------------------------------
Hello, I am not sure if this is a bug or just a question. I have a linear
algebra library which is allocating vectors etc. on the heap, I think
mostly with newForeignPtr. When I use my library in ghci, and turn on
debugging, it becomes clear that vectors I create are being garbage
collected about one second after they are created:
{{{
> let v = ...
> v
(prints debugging info as v is computed)
(prints representation of v)
> (one second later, prints a debugging message
indicating that v has been freed)
}}}
Thus, the fact that ghci still has a symbol called 'v' is not enough to
keep its data from being GC'ed, it seems. Is this a feature? If I create a
string from the same data, then the string is ''not'' GC'ed:
{{{
> let v = ...
> let vstr = show v
> vstr
(prints debugging info as v is computed)
(prints quoted representation of v)
> (one second later, prints debug message
indicating that v has been freed)
> vstr
(prints quoted representation of v as above,
but no computation / no debugging messages,
indicating that 'vstr' data was not GC'ed)
}}}
I can provide more background if necessary. In my library, the primary
datatypes interfacing to foreign blocks are:
{{{
-- Allocated blocks
-- uses 'newForeignPtr finalizerFree'
type RAlloc e i = (ForeignPtr CChar, ForeignPtr e)
-- "Raw Sparse Vector"
data RSV e i = RSV (ForeignPtr (RSV e i)) (RAlloc e i)
deriving Typeable
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2105>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs