[gtfs-transformer-api] Free memory

25 views
Skip to first unread message

Jose Luis Montesinos

unread,
Apr 4, 2012, 5:34:55 AM4/4/12
to OneBusAway API
Hi, I'm developing an application using onebusaway-gtfs (API). The
trouble is that it use lots of memory and I don't know how to free the
memory (I know java's garbage collector). But I close the GtfsDaoImpl
and GtfsReader and nothing happens. Besides I
"clearAllEntitiesForType" of the store (GtfsDaoImpl) but java doesn't
free memory. (I'm using jconsole to monitor the app.

Any ideas to help me? Thanks.

Brian Ferris

unread,
Apr 4, 2012, 6:12:07 AM4/4/12
to onebusa...@googlegroups.com
I'm not sure why the memory is still sticking around. When I have
issues like this, I typically do the following:

1) Use jmap to generate a memory dump of the application (jmap
-dump:file=heap.bin).
2) Use the Eclipse Memory Analysis Tool (http://www.eclipse.org/mat/)
to load up the heap dump.
3) Find the offending object that' still sticking around when you
don't want it to.
4) Find the shortest path to the GC Root to figure out the chain of
references that is keeping the object in scope.

It'd be great if you could try that on your own application. However,
if that's a bit too much, I could try to reproduce your situation.
I'd need more details on how you are using the library, ideally with
some code snippets if you have them.

Thanks,
Brian

> --
> You received this message because you are subscribed to the Google Groups "OneBusAway API" group.
> To post to this group, send email to onebusa...@googlegroups.com.
> To unsubscribe from this group, send email to onebusaway-ap...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/onebusaway-api?hl=en.
>

Jose Luis Montesinos

unread,
Apr 4, 2012, 11:24:49 AM4/4/12
to OneBusAway API
Hi, first of all thank Brian.
My App is just a jpanel with 13 tabs, in each tab I put a table; one
table for each file of GTFS (agency.txt, stops.txt, etc)

But just reading a .zip (a big GTFS file; 25mb compressed, 150mb
decompressed), the app use ~950mb of heap memory, and filling the
tables 150~200mb, total: ~1'1GB
So, nearly all the objects in the heap are used by the API, and using
a profiler I see that there are a lot of char[], String, Double,
Integer, AgencyAndId and HashMap$Entry

I paste the code and the project
http://dpaste.com/726787/

The project (NetBeans project, you can run it launching the applet
test)
http://d.pr/lIGG

The API works fine, but I dont understand why the GC doesn't work if
we are removing the elements. I don't want an app that it comitt 1'4
GB.

The GTFS file that I use: http://www.gtfs-data-exchange.com/agency/trimet/
(trimet_20120330_0324.zip )

Thanks again!

Brian Ferris

unread,
Apr 11, 2012, 3:09:58 AM4/11/12
to onebusa...@googlegroups.com
Hey Jose,

I just got around to look at your code. In the ControllertPanel
class, is there a reason you create the GtfsReader as a member
variable instead of as a local variable inside of the initListener()
method. If you made it a local, it would go out of scope at the end
of the reader try { } block, freeing any internal memory stored
within.

Brian

Jose Luis Montesinos

unread,
Apr 12, 2012, 3:58:09 PM4/12/12
to OneBusAway API
There isn't reason, but even I made it local, GC doesn't free the
memory :(
Reply all
Reply to author
Forward
0 new messages