Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Can GC be BLOCKed?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-12-01 (19:13)
From: Chris King <colanderman@g...>
Subject: Re: [Caml-list] Can GC be BLOCKed?
On 12/1/06, Neal Wang <> wrote:
> The problem is that:
>  When an object is being loaded through an "sql" select stmt, GC is
> then invoked to reclaim memory which will in turn call finalise
> functions to store some objects into db.  At this moment, the db has
> been locked by the select stmt, and the storing procedure fails.  The
> problem is due to sqlite3 doesn't provide row level locks.  A simple
> solution is to prevent GC from calling finalise functions whenever we
> are loading an object into memory.

Have you thought about simply postponing the write-back until the
database is unlocked?  If the finalization function finds that the
database is locked, it can place the data to be written into a global
queue.  (This is possible because finalization functions in O'Caml are
allowed to make their data reachable again.)  This queue can then be
flushed when the database is unlocked.  You could easily extend this
to support queueing of any operation by queueing functions instead of

Hope this helps!

- Chris King