You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by john robens <jr...@interlated.com.au> on 2010/02/03 02:24:53 UTC
Why does this route use a lot of memory? Camel JPA.
Hi again
This one -
from("file:../../../data/
clients?noop=true").convertBodyTo(Client.class).to("jpa:au.com.interlated.server.domain.Client");
I uploaded 300k records - 90mb in total. The java image said it had 2.7Gb of
RAM allocated before it bombed out due to heap space.
Client.class is just a spring entity bean - xml annotations.
Cheers
John
--
http://interlated.com.au
0434 996 607
Re: Why does this route use a lot of memory? Camel JPA.
Posted by Kevin Jackson <fo...@gmail.com>.
Hi,
> from("file:../../../data/
> clients?noop=true").convertBodyTo(Client.class).to("jpa:au.com.interlated.server.domain.Client");
>
> I uploaded 300k records - 90mb in total. The java image said it had 2.7Gb of
> RAM allocated before it bombed out due to heap space.
I had a similar problem, I resolved it using
<from uri="file://">
<split streaming="true"> (and some tokenize string - typically '\n')
<to>
</split>
Essentially without the split + streaming, the entire file is retained
in memory and any objects created from that file have a strong
reference to the input data and cannot be gc'd. By streaming the file
(I guess each line of input represents a 'record'), you only retain
one 'record' in ram at a time and after the object has been created
and persisted, then it becomes eligible for gc as the underlying
bytestream it was attached to no longer has any references.
Another advantage of this approach is that downstream processing can
take place before the entire file has been read. This is how SAX
works (as opposed to DOM which must read the entire file before being
useful).
The caveat to this is that each record in the input must be self
contained so that it is sensible to split the file on a record
boundary, if the file has a header section which contains lookup data
for each record, then all the records, then a simple split won't work
and you would have to pre-process the file to get the lookup data then
post process (splitting and streaming) ignoring the header records
(you can tell this is fresh in my mind as I have had exactly the same
problems)
Thanks,
Kev
Re: Why does this route use a lot of memory? Camel JPA.
Posted by Mick Knutson <mk...@baselogic.com>.
Just a guess, but 90mb * 300K == 27,000,000mb
It appears that each iteration of the transformation is not releasing the
reference to each new Client.
---
Thank You…
Mick Knutson, President
BASE Logic, Inc.
Enterprise Architecture, Design, Mentoring & Agile Consulting
p. (866) BLiNC-411: (254-6241-1)
f. (415) 685-4233
Website: http://www.baselogic.com
Linked IN: http://linkedin.com/in/mickknutson
Twitter: http://twitter.com/mickknutson
Vacation Rental: http://tahoe.baselogic.com
---
On Tue, Feb 2, 2010 at 5:24 PM, john robens <jr...@interlated.com.au>wrote:
> Hi again
>
> This one -
>
> from("file:../../../data/
>
> clients?noop=true").convertBodyTo(Client.class).to("jpa:au.com.interlated.server.domain.Client");
>
> I uploaded 300k records - 90mb in total. The java image said it had 2.7Gb
> of
> RAM allocated before it bombed out due to heap space.
>
> Client.class is just a spring entity bean - xml annotations.
>
> Cheers
> John
>
>
> --
> http://interlated.com.au
> 0434 996 607
>