on develop help sign in
One more GC-related fix
900268cRyan Trinkle
src/Reflex/Spider/Internal.hs+5
@@ -765,6 +765,10 @@ subscribe e ws = do
765 liftIO $ subscribeEventSubscribed subd ws
765 liftIO $ subscribeEventSubscribed subd ws
766 return subd
766 return subd
767
767
768+noinlineFalse :: Bool
769+noinlineFalse = False
770+{-# NOINLINE noinlineFalse #-}
771+
768getRootSubscribed :: Root a -> EventM (RootSubscribed a)
772getRootSubscribed :: Root a -> EventM (RootSubscribed a)
769getRootSubscribed r = do
773getRootSubscribed r = do
770 mSubscribed <- liftIO $ readIORef $ rootSubscribed r
774 mSubscribed <- liftIO $ readIORef $ rootSubscribed r
@@ -779,6 +783,7 @@ getRootSubscribed r = do
779 -- Strangely, init needs the same stuff as a RootSubscribed has, but it must not be the same as the one that everyone's subscribing to, or it'll leak memory
783 -- Strangely, init needs the same stuff as a RootSubscribed has, but it must not be the same as the one that everyone's subscribing to, or it'll leak memory
780 uninit <- rootInit r $ RootTrigger (subscribersRef, rootOccurrence r)
784 uninit <- rootInit r $ RootTrigger (subscribersRef, rootOccurrence r)
781 addFinalizer subscribed $ do
785 addFinalizer subscribed $ do
786+ when noinlineFalse $ putStr "" -- For some reason, without this line, the finalizer will run earlier than it should
782-- putStrLn "Uninit root"
787-- putStrLn "Uninit root"
783 uninit
788 uninit
784 liftIO $ writeIORef (rootSubscribed r) $ Just subscribed
789 liftIO $ writeIORef (rootSubscribed r) $ Just subscribed