[reactive] Space leak if sub-Behaviors dynamically generated?

Robin Green greenrd at greenrd.org
Sun Nov 23 04:01:24 EST 2008


I am trying to use Reactive to write a build system, initially for
Haskell modules, which stays running and rebuilds stuff when files are
modified, created etc. However, I have run into a problem with adding
files to the project to be built.

Suppose you generate separate Behaviors for the contents of each file
(Behavior (Maybe ByteString)). Then, whenever you add a new file, a new
Behavior must be dynamically created, which records Just the contents of
this file, or Nothing when it did not exist, from the application
startup time onwards. ("Dynamically created" because it's not possible
to statically list all the filenames the developer might choose to use,
obviously!)

It seems to me that this entails, by the very design of Reactive,
keeping around the complete contents of every version of every file,
forever. *We* know that the old contents, if any, are "dead", but the
garbage collector probably won't be able to detect that.

If, on the other hand, you just have one single Behavior for
this purpose (Behavior (Map FilePath ByteString)), this will change any
time *anything* changes on the filesystem, so it doesn't directly
support triggering a recomputation/recompilation based on *particular*
changes.

This problem seems to me to generalise to any case where you are trying
to dynamically generate "sub-behaviors" from existing Behaviors, at
arbitrary points in time.

Is my analysis correct? Have I missed something?

-- 
Robin


More information about the Reactive mailing list