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

David Sankel camior at gmail.com
Mon Nov 24 16:31:35 EST 2008

Hi Robin,

How about using an Event (Behavior ByteString)? At each occurrence of
the event, a file comes into existence. If you'd like to optimize out
files that no longer exist, you might try Event (Behavior ByteString,
TimeT) where the time represents when the behavior no longer has any
valid information (_|_).

Does that answer your question?


On Sun, Nov 23, 2008 at 4:01 AM, Robin Green <greenrd at greenrd.org> wrote:
> 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
> _______________________________________________
> Reactive mailing list
> Reactive at haskell.org
> http://www.haskell.org/mailman/listinfo/reactive

David Sankel
Sankel Software

More information about the Reactive mailing list