Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak using gridWithHalves #69

Open
jwiegley opened this issue Apr 27, 2017 · 0 comments
Open

Memory leak using gridWithHalves #69

jwiegley opened this issue Apr 27, 2017 · 0 comments

Comments

@jwiegley
Copy link

I tried to make an nearly empty grid 1000 by 1000 cells, but after it used 40 GB of system memory I had to kill it. Sample code:

{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}

module Main where

import Control.Lens hiding ((#))
import Data.Default
import Data.List
import Data.List.Split
import Data.Typeable
import Diagrams.Backend.SVG.CmdLine
import Diagrams.Prelude
import Diagrams.TwoD

default (Int)

example :: Int -> Int -> [((Int, Int), (Double, Double), Colour Double)]
        -> Diagram B
example n m =
    foldr (\((x, y), (w, h), c) -> situate x y w h c)
        $ gridWithHalves n m
  where
    situate x y w h c =
        flip placeDiagramOnGrid [((x*2)+1, (y*2)+1) :: (Int, Int)]
            $ rect (w / fromIntegral n) (h / fromIntegral m)
                # alignTL
                # lc c
                # fc c

main :: IO ()
main = mainWith $ example 1000 1000 shapes
  where
    shapes = [ ((3, 4), (2, 2), black)
             , ((5, 7), (3, 1), red)
             ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant