Skip to content

Option to not cache flows or export the flow cache in index.js #76

Closed
atrniv opened this Issue Sep 10, 2013 · 1 comment

2 participants

@atrniv
atrniv commented Sep 10, 2013

I use nools to create a large number of flows dynamically from a set of flow definitions. Each flow definition is stored by a unique name which i use to create the flow object.

These flow objects are then managed by a LRU cache which disposes the flow object when required.

However in certain scenarios the LRU cache is destroyed and dispose is not called. In this case I have no more references available of all my previously created flows and when i try to recreate them I get an error saying they already exist.

I can bypass this by asking nools if the flow exists before recreating it.

However what do I do in the scenario when I never recreate a flow again. Wouldn't there be a memory leak caused due the reference maintained on the flows cache in index.js ?

An example to show more clearly what i mean

  • I create cache 1
  • I create Flow A and store in cache 1
  • I create Flow B and store in cache 1
  • I delete cache 1
  • I create cache 2
  • I create Flow A and find it already exists so i use it and store it in cache 2
  • I create Flow C and store it in cache 2

In this case if i never try to create Flow B again it will forever remain in the flows object and never be removed from memory.

I think there should be an option to disable storing a created flow in the flows cache in index.js or else this should be exported so that it can be cleared manually when needed.

@doug-martin doug-martin was assigned Sep 11, 2013
@doug-martin doug-martin added a commit to doug-martin/nools that referenced this issue Sep 24, 2013
@doug-martin doug-martin v0.1.13
* Fixed issue #68 where `matchUntilHalt` uses a lot of CPU
* Fixed issue #45, now compiled rules support `or` constraint with more than 2 inner constraints.
* Added new feature to address #76, now you can use `deleteFlows` to dispose all flows, or use `hasFlow` to check if a flow is already registred with `nools`.
4aadfe6
@doug-martin doug-martin referenced this issue Sep 24, 2013
Merged

v0.1.13 #77

@doug-martin
C2FO member

As of v0.1.13 you can call nools.deleteFlows which will clear all flows or you can call nools.hasFlow to check if a flow exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.