I'm back to a memory problem I posted about a little while back, but I
thought I had put down to garbage collection problems with some
pointers from Jeppe. I'm pretty sure now that it's not a GC issue, as
I have profiled the app in VisualVM.
Basically, I'm iterating over a file and using Mapper to save a row to
the database for each line. The problem is that the mapper objects I
am creating in the loop don't seem to be getting garbage collected,
and I don't know why, unless Mapper is retaining references to them
somehow. Is there something I have to do explicitly dereference
mapper objects? As they are created in the foreach block, I don't see
how I could be accidentally retaining them otherwise.
I would very much appreciate any help, as I am struggling with this
one...as it's for a live project, if I can't get to the bottom of it
soon, I'm going to have to strip out the Mapper code and do it the old-
fashioned way.
Paraphrased code below. There may be typos in this, but you get the
idea. The 'row' is the object which I seem to be accumulating many
instances of, according to VisualVM.
Thanks for any help,
Matt
parser.foreach{line =>
val row = Row.create
row.generatedTime(generatedTime)
//set other fields...
//Look up some other data...
OtherMappedObject.findAllDb(CoreDB,
By(OtherMappedObject.id,
row.otherObjId)).firstOption.foreach{obj =>
row.objName(obj.name)
}
//A nice calculated field...
val x = BigDecimal(row.amount.is) * row.rate.is
row.total(x)
row.save
}
Hi All,
I'm back to a memory problem I posted about a little while back, but I
thought I had put down to garbage collection problems with some
pointers from Jeppe. I'm pretty sure now that it's not a GC issue, as
I have profiled the app in VisualVM.
Basically, I'm iterating over a file and using Mapper to save a row to
the database for each line. The problem is that the mapper objects I
am creating in the loop don't seem to be getting garbage collected,
and I don't know why, unless Mapper is retaining references to them
somehow. Is there something I have to do explicitly dereference
mapper objects? As they are created in the foreach block, I don't see
how I could be accidentally retaining them otherwise.
I would very much appreciate any help, as I am struggling with this
one...as it's for a live project, if I can't get to the bottom of it
soon, I'm going to have to strip out the Mapper code and do it the old-
fashioned way.
Paraphrased code below. There may be typos in this, but you get the
idea. The 'row' is the object which I seem to be accumulating many
instances of, according to VisualVM.
Thanks for any help,
Matt
parser.foreach{line =>
val row = Row.create
row.generatedTime(generatedTime)
//set other fields...
//Look up some other data...
OtherMappedObject.findAllDb(CoreDB,
By(OtherMappedObject.id,
row.otherObjId)).firstOption.foreach{obj =>
row.objName(obj.name)
}
//A nice calculated field...
val x = BigDecimal(row.amount.is) * row.rate.is
row.total(x)
row.save
}
--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.