OutOfMemoryError when persisting a lot of objects

Hi,
I tried to fill up a firebird and hsql database
to test their behaviour like this:
TestObject tobj;
Random rnd = new Random();
int cnt=1;
while(cnt<2500000) {
if(cnt%100==1) tx.begin();
tobj = new TestObject();
tobj.setSomeValue(rnd.nextInt());
pm.makePersistent(tobj);
if(cnt%100==0) {
tx.commit();
System.out.println(cnt);
cnt++;
This results in
1368300
1368400
1368500
1368600
Exception in thread "main" java.lang.OutOfMemoryError
or similar.
Does this mean, that there might be a problem in long running apps?
Any hints or remarks?
Regards,
Thomas

Hi Abe,
thank you for your answer.
We'll investigate this, but unless configured to do so, Kodo does not
typically use any unbounded hard caches.I have to admit, that I do not know how to configure Kodo in respect
to its hard cache behaviour.
Because you are testing against in-memory databases,
you might be running into database limitations.
Have you tried running your test against a "real" database?I did not use hsql as in-memory database. I verified that
the database file was growing while running the test.
Firebird (Interbase) could perhaps be called "real" at least
in so far, that it is running as a (non-java) server, independent
from the VM running Kodo and the JDBC.
Please let me know, if you want me to install mysql or postgres
and repeat the test.
Perhaps this could be regarded as a hint, that the problem may be
related to Kodo:
If I close the PM every 1000 persisted Objects and request it again
from the PMF the error does not occur anymore.
(Of course without having modified the database or kodo setup.)
TestObject tobj;
Random rnd = new Random();
int cnt=1;
while(cnt<2500000) {
if(cnt%1000==1) {
pm = pmf.getPersistenceManager();
tx = pm.currentTransation();
if(cnt%100==1) tx.begin();
tobj = new TestObject();
tobj.setSomeValue(rnd.nextInt());
pm.makePersistent(tobj);
if(cnt%100==0) {
tx.commit();
System.out.println(cnt);
if(cnt%1000==0) pm.close();
cnt++;
Please excuse some newbe questions related to this workaraound:
Is the cache released with the PM or is it associated with the PMF?
Do several PMs share a common cache?
Best regards,
Thomas

Similar Messages

  • OutOfMemoryError when retrieving large resultset

    In my application I have one type of object (Call it O for now) that has
    a lot of data in the database (+50000 rows). Now I need to create an
    object of class T that has a m-n binding to 40000 instances of O. In the
    database this is mapped to a link table between the table for O and T.
    Now I get an OutOfMemoryError when I perform the following code to add
    one T to the aforementioned O:
    PersistenceManager pm = VRFUtils.getPM(getServlet());
    T t = new T();
    //Fill arbitrary fields
    t.setToelichting(mtForm.getToelichting());
    //Add T to a set of O's
    Set os = new HashSet();
    Query q = pm.newQuery(O.class,"aangemaakt==parmaanmaak");
    q.declareParameters("java.util.Date parmaanmaak");
    os.addAll(q.execute(field));
    t.setOs(os);
    //Make T persistent
    pm.currentTransaction().begin();
    pm.makePersistent(toelichting);
    pm.currentTransaction().commit();
    pm.close();
    After debugging I've found that the OutOfMemoryError occurs even when I
    don't make anything persistent, but simply run the query that retrieves
    40000 records and do a c.size() on the result.
    I'm running Kodo against MySQL using Optimistic transactions.
    What I must appreciate, is that the OutOfMemoryError does not upset the
    rest of the Kodo system.
    Please advise,
    Martin van Dijken
    PS: The c.size() issue I've been able to resolve using KodoQuery's
    setResult("count(this)"), but I can't think of anything like that, that
    would apply to this situation.

    As you may know, Kodo has several settings that allow you to use large
    result sets without running out of memory (assuming your driver supports
    advanced features):
    http://www.solarmetric.com/Software/Documentation/latest/docs/ref_guide_dbsetup_lrs.html
    Kodo also allows you to apply these settings to persistent fields, so
    that the entire collection or map field does not reside in memory:
    http://www.solarmetric.com/Software/Documentation/latest/docs/ref_guide_pc_scos.html#ref_guide_pc_scos_proxy_lrs
    Unfortunately, you are trying to create a relation containing more
    objects than your system can handle, apparently, and when creating a
    relation you pretty much have to load all the related objects into
    memory at once right now.
    In the next beta release of 3.1, there is a solution to this problem.
    Our next release no longer holds hard references to objects that have
    been flushed. So by using the proper large result set settings as noted
    above, and by making your relation a large result set relation also as
    noted above, and by adding only a few hundred objects at a time from the
    query result to the relation and then manually flushing, you should be
    able to perform a transaction in which all the queried objects are
    transferred from the query result to the large result set relation
    without exhausting memory.

  • Crashes consistently when control clicking a selected object

    CS4 InDesign crashes consistently when control clicking a selected object. Preferences have been reloaded, the program has been reinstalled, all without any effect towards this issue. Any suggestions?

    Yeah, it was InDesign Hangs when right clicking on graphic.
    There was a lot of head-scratching and the rather unsatisfying conclusion was when the OP removed ancient applications that might have been a choice for "Edit Original," then the problem went away.
    I guess the conclusion is that right-clicking on an image iterates over the possible apps that can open an image (for Edit With and Edit Original) and does [something], and for some reason that [something] was hanging. Not clear what the app was. But presumably if you right click the file in the Finder and look at the list provided by Open With, it is similar.
    Or you could try the suggestions I offered to the OP in that thread that it looks like he never used.

  • What happens to objects when you redeclare a new object?

    ... and is there a more proper way of "deleting" them from memory, or is it a case of waiting until the garbage collector in java sweeps them up?
    i.e.
    private CustomObjectType myObject;
    public final void myMethod() {
    myObject = new CustomObjectType("I am the first object");
    // do some temporary work with myObject
    /// now I need to do more work with another temporary object, so just replace the "link"
    myObject = new CustomObjectType("I am a second object");
    Is it better to declare new variables to hold this second object?
    Should a person declare the object to be null when no longer required?
    Do I ever need to worry about this, does the garbage collector sort out references for me?
    (Please go easy, still learning and don't really need to know this right now but I'm curious! :)

    What happens to objects when you redeclare a new object?If you go:
    Dog myDog = new Dog();
    and then go:
    Dog myDog = new Dog();
    you are replacing the first reference to Dog() with another one. I don't think it would make sense to do this because it is redundant.
    But if you go:
    static Dog myDog = new Dog();
    and then go:
    static Dog myDog = new Dog();
    then then second one will be ignored because the first one already assigned Dog() to myDog.. so the second one won't replace the first one - it will just be ignored or generate an error.
    is there a more proper way of "deleting" them from memory, or is it a case of waiting until the garbage collector in java sweeps them up?In c and c++ you have to think about when the life of an object ends and destroy the object to prevent a memory leak. But in Java the garbage collector takes this task on if a certain amount of memory is used. If you don't use a lot of memory the gc won't bother and the objects will be destroyed when you exit the program.
    You can use:
    finalize(){
    // insert code to be executed before the gc cleans up
    and if you call System.gc() (which you probably won't need to do) then the code in the finalize() method will run first e.g. to erase a picture from the screen before collecting the object.
    private CustomObjectType myObject;public final void myMethod() {
    myObject = new CustomObjectType("I am the first object");
    // do some temporary work with myObject
    /// now I need to do more work with another temporary object, so just replace the "link"
    myObject = new CustomObjectType("I am a second object");
    you could do:
    public class CustomObjectType{
        //this constructs an instance of the class using a string of your choice
        CustomObjectType(String str) {
            System.out.println(str);
        static void main(String[] args){
            CustomObjectType myObject = new CustomObjectType("I am the first object");//  This sends the constructor the string you want it to print
            CustomObjectType myObject2 = new CustomObjectType("I am the second object");//  This sends the constructor the string you want it to print
    }Bruce eckel wrote Thinking in Java 4th edition considered to be the best book on Java because of how much depth he goes into, although some recommend you should have atleast basic programming knowledge and a committment to learn to get through the book.
    I just started it and it helps a lot. Maybe u could borrow it from the library.. good luck!

  • I'm trying to make an android game and I want that when a collision with another object change of sc

    I'm trying to make an android game and I want that when a collision with another object change of scene
    how i can do this

    here is the doc on htiTestObject for detecting collisions.
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayOb ject.html#hitTestObject()
    for scene change use the second parameter in gotoandplay() to define scene name doc below
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/MovieClip .html#gotoAndPlay()

  • When a Method Returns an Object, does it return a copy or a pointer?

    When you have a method that returns an Object, is the Object returning a copy of the Object returned inside
    of the Method or is it an Actual pointer to the Object inside of the method's coresponding Object?
    so say you have an object ...
    Class Something {
    JLabel myLabel = new JLable("myLabel");
    public JLabel getLabel() {
    return myLabel;;
    Something something = new Something();
    JLable theLabel = something.getLabel()
    theLable.setString("theLable");
    so when I setString on the Object theLabel , am I going to change the value of myLabel inside of the Object something?

    Yes, it returns a pointer.

  • Error when determining  a number from object BI_ODS

    Error When determining a number from object BI_ODS and number 01  when flat file source system is assigned to transfer rules of infosource , when activating this error occured .
    plz need solution.

    Hi,
    Number ranges can be maintained through the transaction SNRO. For details check:
    http://help.sap.com/saphelp_nw70/helpdata/EN/2a/fa02e3493111d182b70000e829fbfe/frameset.htm
    Rgds-
    Sonal

  • Error when determining a number from object BI_TSDTEL and number 01

    Hi BW Experts,
    After Transporting Infosources (Master & Transaction) to BW QA, the transfer rules were not getting activated in QA. The following error message was diaplyed.
    "Error when determining a number from object BI_TSDTEL and number 01
    Object name can only contain characters from syntactical character set
    Object name can only contain characters from syntactical character set
    Data element for InfoObject KOKRS 0CO_AREA could not be created
    Data element for InfoObject KOKRS 0CO_AREA could not be created
    Transfer structure 0IM_FA_IQ_2_SB activated under the name 0IM_FA_IQ_2_SA
    It is not necessary to copy dependent objects for transfer structure 0IM_FA_IQ_2_SA
    Transfer structure 0IM_FA_IQ_2_SA does not exist
    Error RSAR 440 when handling objects with type R3TR ISTS."
    I have gone through the Note: 674818.
    Could someone clear me about BI_TSDTEl, By using this do we need to maintain object intervals manually in all the systems like BW ( Dev & QA ), R/3 (Dev & QA).
    Because  I have not seen the Intervals in R/3 ( Dev & QA) systems.
    please could someone provide Inputs for this.
    Thanks in Advance
    Regards
    SK

    Hi,
    Try to see that transfer structure is existing in the sytem which is connecting in
    the BW quality.
    You need the same to be transported from the development server of R/3 to quality server of R/3.
    Just check if this helps.
    Regards
    Rahul Bindroo

  • Orchestration exception:Exception occurred when persisting state to the database because of special character ' ' in HL7 message.

    In some scenarios HL7 message is coming with special character ‘’ and HL7 dis-assembler escaping this character with “&#x10;&#x1;”. But while sending out (pass thru pipeline but orchestration trying to persist here at last sendshape.) from orchestration
    this message failing with the error “Exception occurred when persisting state to the database.”
    As per the analysis , Orchestration is unable to convert to xml document from a
    XLANGMessage because of this special character. We have tried to call custom .net class with following code and its failing here as well (I think orchestration also trying to do same way and failing with the message and failing with same error.).
    public void ProcessRequest(XLANGMessage reqMessage)
    XmlDocument xmlDocument = (XmlDocument)reqMessage[0].RetrieveAs(typeof(XmlDocument)); It is failing here with the error
    “ ', hexadecimal value 0x10, is an invalid character. Line 1, position 1865. “
    Note : Please find the special character in the attachment circled in red color. 

    Hi ,
    Please find the xml and the screenshot.
    <OBX_ObservationResult>
      <OBX_1_SetIdObx>3</OBX_1_SetIdObx>
      <OBX_2_ValueType>TX</OBX_2_ValueType>
      <OBX_3_ObservationIdentifier>
        <CE_0_Identifier>P.112</CE_0_Identifier>
        <CE_1_Text>Where pt. will be transported to \T\ where &#x10;&#x1;famly can wait:</CE_1_Text>
      </OBX_3_ObservationIdentifier>
      <OBX_4_ObservationSubId />
      <OBX_5_ObservationValue>Y</OBX_5_ObservationValue>
      <OBX_6_Units>
        <CE_0_Identifier />
      </OBX_6_Units>
      <OBX_7_ReferencesRange />
      <OBX_8_AbnormalFlags />
      <OBX_9_Probability />
      <OBX_10_NatureOfAbnormalTest />
      <OBX_11_ObservationResultStatus>N</OBX_11_ObservationResultStatus>
    </OBX_ObservationResult>

  • Firefox 4 isn't turning the cursor to pointer mode when it goes over an object in a flash movie that has the 'buttonMode' property set to 'true'. Can this be fixed?

    I make flash games for a living, and normally when I set something to 'buttonMode' inside Flash, the cursor turns into the pointer when it rolls over the object. This is how it was in the previous version of FF and how it is in Safari and IE.
    But this isn't happening in FF4. The cursor is not turning into the pointer. Kind of a bummer. This is a tool so that the kids who play the games I make know when something is clickable.

    It seems to be an issue, I just posted the same question. I hope they fix it, its a bit annoying. I wonder if they had ex-Microsoft employees working on the updates for 4.0?

  • Is it possible to hide the yellow box that appears when you scroll over any object in the form?

    Is it possible to hide the yellow box that appears when you scroll over any object in the form? This box contains the item name or caption.

    Hi,
    Under Tools ... Options ... Workspace, there is an option "Display Object Name Tool Tips While Pointing".
    Try clearing that.
    Bruce

  • Possibility of Stock posting when the inspection lot is in created status?

    Dear,
    Is it possible to do stock posting when the inspection lot is in created status?
    Please help. Yor suggestion will be appriciated.
    Regards
    Vivek Deshpande

    hi
    In standard the creation status wont allow to post the material ,another way is change the system status CRTD in BS22 and allow inventory posting( i haven't checked)
    regards
    thyagarajan

  • Error when trying top connect ChooseFromList object to a Button object

    Hi all
    I have a user form with a button .
    upon pressing on the button i want that a ChooseFromList screen will be opened. when i create the ChooseFromList object and bind it to the button object by assigning its UID to the button's ChooseFromListUID property i recieve an error message that says: "Invalid choose from list".
    what could be causuing this problem? what is the correct way in code to connect a ChooseFromList object to a Button object?
    appreciate the help
    Yoav

    Hi Yoav,
    Before Doing the Bind, you should add your CFL
    Dim oCFLs As SAPbouiCOM.ChooseFromListCollection
    Dim oCFL As SAPbouiCOM.ChooseFromList
            Dim oCFLCreationParams As SAPbouiCOM.ChooseFromListCreationParams
    oCFLs = oFrm.ChooseFromLists
                oCFLCreationParams = SBO_App.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_ChooseFromListCreationParams)
                '1. BP CFL
                oCFLCreationParams.MultiSelection = False
                oCFLCreationParams.ObjectType = SAPbobsCOM.BoObjectTypes.oBusinessPartners
                oCFLCreationParams.UniqueID = cflName
                oCFL = oCFLs.Add(oCFLCreationParams)
    The correct way to connect a CFL to a button is like this
    Dim oBtn As SAPbouiCOM.Button
    oBtn = oFrm.Items.Item("btnCFL").Specific
    oBtn.ChooseFromListUID = cflName

  • How to set the selectedIndex when dataProvider is an XML object in DropDownList?

    dataProvider was an XML object
    How to set the selectedIndex when dataProvider is an XML object in DropDownList?
    I do this:
    <s:DropDownList id="dropDownList" requireSelection="true" selectedIndex="2"
                    labelField="lastName" dataProvider="{employeeService.lastResult.employees.employee}"/>
    But always the first item is selected whatever the value of selectedIndex equals to.

    if i understand correctly, you want the selectedindex to be 2 when the DropDownList  displays.
    It might be the case that the dataprovider is being sought after it's already selected its index (as the dataprovider isn't already determined to begin with), so currently it's
         - setting the selected index to default
         - setting the selected index to 2 (your command)
         - getting the dataprovider
         - setting the selected index to default
    try writing a function to set the DropDownList's selected index after it's received the information, or even just attach it to the employeeService result handler.
    for quick testing sake you could just add
    <s:DropDownList id="dropDownList" requireSelection="true" updateComplete="dropDownList.selectedIndex = 2"
                    labelField="lastName" dataProvider="{employeeService.lastResult.employees.employee}"/>
    to see if my theory is correct.

  • [svn:bz-trunk] 18926: bug fix BLZ-570 Double linked list with lot of objects result in BlazeDS Error deserializing error  : StackOverflowError

    Revision: 18926
    Revision: 18926
    Author:   [email protected]
    Date:     2010-12-01 14:07:19 -0800 (Wed, 01 Dec 2010)
    Log Message:
    bug fix BLZ-570 Double linked list with lot of objects result in BlazeDS Error deserializing error : StackOverflowError
    We put hard limit to the max object nest level to prevent StackOverFlowError. the default max object nest level is 1024 and it can be configured in the endpoint/serialziation section in service-config.xml.
    This needs documentation.
    Checkintests pass
    Ticket Links:
        http://bugs.adobe.com/jira/browse/BLZ-570
    Modified Paths:
        blazeds/trunk/modules/common/src/flex/messaging/errors.properties
        blazeds/trunk/modules/core/src/flex/messaging/endpoints/AbstractEndpoint.java
        blazeds/trunk/modules/core/src/flex/messaging/io/SerializationContext.java
        blazeds/trunk/modules/core/src/flex/messaging/io/amf/Amf0Input.java
        blazeds/trunk/modules/core/src/flex/messaging/io/amf/Amf3Input.java
        blazeds/trunk/modules/core/src/flex/messaging/io/amf/AmfIO.java

Maybe you are looking for

  • New features present in oracle 11gr2.

    Hi all, I would like to know the new features present in oracle 11gR2. Any pointers would be helpful. Example: list aggregate features is not there in 11gR1... etc. Thanks and Regards Nagaraja Akkivalli.

  • Do I interact with the browser or Plug-in

    I am interested in how Flash gets displayed in a web browser and how much of the interaction and display is dependant on the web browser. If you interact with a flash application on a web browser are you really interacting with the browser first whic

  • How to perform logical comparison using struts

    Hi all, I know this is probably not the best forum for a question regarding struts, but am sure most developers here are familiar with it. how do you implement this using struts logic present or logic no present tags ? if ((a != null ) && (b != null)

  • Httpservletrequest in jsf

    i have an application in jsf from a previous college. now i have to implement security in it. it would be easy to do it in struts for me, but in this jsf application i'm totally lost. i see no httpservlet object in the application. i need to do getRe

  • Help with Bios Password Reset Service

    I am trying to use the Bios Password Reset Service for Power On password and Hard Drive Password. The current setting in the Bios is "Enabled, In Progress". The Bios sidebar help tells me that in order to complete registration for this function to op