[HOpenGL] Memory Leak
Shawn Garbett
shawn.p.garbett at vanderbilt.edu
Tue Jan 27 17:29:30 EST 2009
Saizan on IRC offered the following solution:
data Leak = Leak {x :: !Integer}
Tested it and it works!
> On Jan 27, 2009, at 1:07 PM, Shawn Garbett wrote:
>
>> I'm pulling my hair out fixing a memory leak in an OpenGL program.
>> Don't know if this is related to OpenGL, but I've not gotten any
>> takers from IRC. I know the exact line of code that's causing it.
>>
>
> <snip>
>
> I've gotten it down to this:
>
> import Data.IORef
> import Graphics.Rendering.OpenGL.GL.StateVar
>
> -- LEAKS LIKE A SIEVE
> data Leak = Leak {x :: Integer}
> data State = State { stuff :: IORef Leak }
>
> iter :: State -> IO ()
> iter state = do
> l <- get $ stuff state
> (stuff state) $=! l{x=((x l) + 1 `rem` 12)}
> iter state
>
> main :: IO ()
> main = do
> l <- newIORef $ Leak{x=0}
> let s = State{stuff = l}
> iter s
>
>> Shawn Garbett <shawn.p.garbett > at < vanderbilt.edu>
>> Vanderbilt Cancer Biology
>> 220 Pierce Ave, PRB 715AA
>> Nashville, TN 37232
>> Office: 615.936.1975
>> Cell: 615.397.8737
>
>
>
>
>
Shawn Garbett <shawn.p.garbett at vanderbilt.edu>
Vanderbilt Cancer Biology
220 Pierce Ave, PRB 715AA
Nashville, TN 37232
Office: 615.936.1975
Cell: 615.397.8737
More information about the HOpenGL
mailing list