Memory usage in Clojure, hprof

109 views
Skip to first unread message

BerlinBrown

unread,
Jun 19, 2009, 10:12:19 AM6/19/09
to Clojure
This may be a throw a comment, but I was running hprof against this
SWT gui application that I have. I have about 10,000 lines of clojure
code, so I don't know where to reduce my memory. But I thought these
stats were interesting on the number of Clojure objects created.
Right now, the apps is eating 20MB of heap memory and here are the top
objects created:

Does anyone know when a LeafNode would be created? Or some of those
other objects.

26625 instances of class clojure.lang.PersistentHashMap$LeafNode
8938 instances of class clojure.lang.PersistentHashMap$INode[]
8898 instances of class clojure.lang.PersistentHashMap
$BitmapIndexedNode
6009 instances of class clojure.lang.Symbol
2081 instances of class clojure.lang.PersistentArrayMap
2021 instances of class clojure.lang.PersistentList
1487 instances of class clojure.lang.Var
1426 instances of class org.eclipse.swt.graphics.TextLayout$StyleItem
1350 instances of class org.eclipse.swt.internal.win32.SCRIPT_ANALYSIS
1350 instances of class org.eclipse.swt.internal.win32.SCRIPT_STATE
960 instances of class clojure.lang.LazilyPersistentVector
574 instances of class clojure.lang.DynamicClassLoader
495 instances of class clojure.lang.PersistentVector
481 instances of class clojure.lang.APersistentVector$Seq
169 instances of class clojure.lang.Keyword
147 instances of class javax.management.MBeanAttributeInfo
120 instances of class clojure.lang.PersistentHashMap

Four of Seventeen

unread,
Jun 19, 2009, 1:04:14 PM6/19/09
to Clojure
On Jun 19, 10:12 am, BerlinBrown <berlin.br...@gmail.com> wrote:
> 574 instances of class clojure.lang.DynamicClassLoader

That is curious. Ordinarily one only needs one instance of any
particular classloader, not 574 of them. :) Not that I know much about
clojure's internals.

Berlin Brown

unread,
Jun 19, 2009, 1:50:09 PM6/19/09
to Clojure
"clojure.lang.DynamicClassLoader "

Could be a misnomer. Not really a classloader in the typical sense.

I think this is my actual code that gets loaded in memory.
"26625 instances of class clojure.lang.PersistentHashMap$LeafNode "

Next, I think I need some memory performance tips to see where I can
reduce memory.

Berlin Brown

unread,
Jun 19, 2009, 4:18:59 PM6/19/09
to Clojure
I am sorry to bother you guys with this randomness, but what I am
looking at is pretty cool.

Exits
Display sleep() 368
RT classForName(String) 1030
Var deref() 701318
core__init load() 1
core$filter_key__4306 invoke(Object,Object,Object) 196
core$ns_publics__4334$fn__4336 invoke(Object) 145158
RT loadClassForName(String) 44
PersistentHashMap$BitmapIndexedNode$Seq next() 261388
PersistentHashMap$BitmapIndexedNode find(int,Object) 145201
Var get() 695863
PersistentHashMap entryAt(Object) 139095
octane_file_utils$open_file_util__552 invoke(Object,Object) 1
PersistentHashMap$BitmapIndexedNode assoc(int,int,Object,Object,Box)
86140
PersistentHashMap$BitmapIndexedNode$Seq first() 332152
PersistentHashMap$BitmapIndexedNode bitpos(int,int) 247501
Var getThreadBinding() 701870
PersistentHashMap assoc(Object,Object) 56120
RT first(Object) 226620
RT next(Object) 178384
core$refer__4345 doInvoke(Object,Object) 196
core$flush__4156 invoke() 7
RT cons(Object,Object) 174573
Namespace findOrCreate(Symbol) 6751
octane_utils__init load() 1
core$val__3614 invoke(Object) 168802


I easily added jrat to profile the method calls. Here is what I came
up with. Here are the clojure classes and how many times they were
executed.

Here is jrat.

http://jrat.sourceforge.net/

Berlin Brown

unread,
Jun 20, 2009, 3:03:07 AM6/20/09
to Clojure
OK, here is another thing I was looking at, number of calls.

The application is mostly geared around this code:

http://code.google.com/p/lighttexteditor/

http://spreadsheets.google.com/pub?key=rNB3pttScIyEdLM_kp2rejg&gid=4
Reply all
Reply to author
Forward
0 new messages