
Hello, I'm trying to allow RGB images as buttons in XMonad. It's alreasy working, but now XMonad leaks a lot of memory (each time you change focus about 1 or 2 megabytes are taken from memory), so when a little time passes, it becomes unusable. I'd like to ask for help profiling or with any other thing that may help me solve this problem. As of now, I'm saving the images as String. Then, using Foreign.C.String.newCAString, I convert it to a CString, which is what Xlib expects. After that, I create a Image using XCreateImage, which I paint using XPutImage. Finally, I call XDestroyImage to free the memory. So, as far as I know, no leak should be possible :( Thanks in advance.

trupill:
Hello, I'm trying to allow RGB images as buttons in XMonad. It's alreasy working, but now XMonad leaks a lot of memory (each time you change focus about 1 or 2 megabytes are taken from memory), so when a little time passes, it becomes unusable. I'd like to ask for help profiling or with any other thing that may help me solve this problem.
As of now, I'm saving the images as String. Then, using Foreign.C.String.newCAString, I convert it to a CString, which is what Xlib expects. After that, I create a Image using XCreateImage, which I paint using XPutImage. Finally, I call XDestroyImage to free the memory. So, as far as I know, no leak should be possible :(
You should recompile xmonad with --enable-executable-profiling -ghc-options=-auto-all and then run it with +RTS -p This will create a .prof file that will tell you what is allocating. For even clearer understanding, use heap profiling, which will graphically display what is being allocated and where. http://book.realworldhaskell.org/read/profiling-and-optimization.html#id6780... -- Don

2010/6/13 Don Stewart
trupill:
Hello, I'm trying to allow RGB images as buttons in XMonad. It's alreasy working, but now XMonad leaks a lot of memory (each time you change focus about 1 or 2 megabytes are taken from memory), so when a little time passes, it becomes unusable. I'd like to ask for help profiling or with any other thing that may help me solve this problem.
As of now, I'm saving the images as String. Then, using Foreign.C.String.newCAString, I convert it to a CString, which is what Xlib expects. After that, I create a Image using XCreateImage, which I paint using XPutImage. Finally, I call XDestroyImage to free the memory. So, as far as I know, no leak should be possible :(
You should recompile xmonad with --enable-executable-profiling -ghc-options=-auto-all and then run it with +RTS -p
This will create a .prof file that will tell you what is allocating.
For even clearer understanding, use heap profiling, which will graphically display what is being allocated and where.
http://book.realworldhaskell.org/read/profiling-and-optimization.html#id6780...
Thanks very much. Just one more question: do I have to change anything when compiling xmonad and xmonad-contrib, or just use those arguments when calling 'xmonad --recompile'?

trupill:
Thanks very much. Just one more question: do I have to change anything when compiling xmonad and xmonad-contrib, or just use those arguments when calling 'xmonad --recompile'?
No, you'll have to compile xmonad by hand (with cabal configure -..flags ; cabal build ; cabal install). -- Don

* On Monday, June 14 2010, Don Stewart wrote:
trupill:
Thanks very much. Just one more question: do I have to change anything when compiling xmonad and xmonad-contrib, or just use those arguments when calling 'xmonad --recompile'?
No, you'll have to compile xmonad by hand (with cabal configure -..flags ; cabal build ; cabal install).
-- Don
You need to call ghc yourself instead of `xmonad --recompile', once you've built the xmonad library with profiling (as Don outlined). xmonad calls ghc for you with more or less: ghc --make xmonad.hs -i -ilib -fforce-recomp -v0 -o ~/.xmonad/xmonad-$arch-$os And `xmonad --recompile' doesn't listen to any additional flags. So you'll have to call ghc yourself, and make sure that you directly run your compiled config with appropriate flags for the RTS. -- Adam

Adam Vogt
* On Monday, June 14 2010, Don Stewart wrote:
trupill:
Thanks very much. Just one more question: do I have to change anything when compiling xmonad and xmonad-contrib, or just use those arguments when calling 'xmonad --recompile'?
No, you'll have to compile xmonad by hand (with cabal configure -..flags ; cabal build ; cabal install).
-- Don
You need to call ghc yourself instead of `xmonad --recompile', once you've built the xmonad library with profiling (as Don outlined). xmonad calls ghc for you with more or less:
ghc --make xmonad.hs -i -ilib -fforce-recomp -v0 -o ~/.xmonad/xmonad-$arch-$os
And `xmonad --recompile' doesn't listen to any additional flags. So you'll have to call ghc yourself, and make sure that you directly run your compiled config with appropriate flags for the RTS.
I wonder: is there any way we can pass additional flags to ghc if we wanted to (say, to enable -O2 or something)? Maybe even pass extra flags to xmonad when restarting it so that we could set up profiling within xmonad itself (though I'm not sure where the resultant profiling output would go... ~/ ?). -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com
participants (4)
-
Adam Vogt
-
Alejandro Serrano Mena
-
Don Stewart
-
Ivan Lazar Miljenovic