×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Jan 2010
    Posts
    52

    Floggy Performance Issue

    Hey guys,

    I'm developing a MIDlet that uses floggy. I'm storing information about people with floggy with a class called Person.
    The class is of course persistable. The Person object has a Version member which determines the current version of the Person object.
    When the application is requested to check for an update, it reads an XML file on the device and parses the data into Person objects and puts them in a Vector.
    This works perfectly (the process of parsing an XML file to a Vector of Persons, that is). My update algorithm is as follows:

    1. Fetch a Person from the Vector
    2. If the Person doesn't exists* in the floggy database, add it
    3. If the Person does exists* in the floggy database, check the version of it
    4. If the version of the Person in the floggy database is lower than the version of the Person fetched, update the floggy database to contain the newest version.
    * Person objects are compared by an ID member

    The algorithm works well, but as it progresses (in terms of iterations), it gets slower and slower -
    for example, it finishes the first few iterations in less than a second, but each iteration after the 50th one takes more than 15 seconds and so forth.

    This is the update algorithm function:

    public void performDataUpdate(Vector data) {
    if (null == data || data.isEmpty()) {
    return;
    }

    for (int i = 0; i < data.size(); i++) {
    if (data.elementAt(i).getClass().equals(Person.class)) {

    try {
    Person person= (Person)data.elementAt(i);
    int local_person_version = getPersonVersionByID(person.getID());

    if (0 >= local_person_version) { //this means that the Person doesn't exists in the DB

    this.saveToDb(person);

    } else {

    if (local_person_version < person.getVersion()) {
    try {

    this.deletePersonByID(person.getID());
    this.saveToDb(pesron);

    } catch (Exception ignored) {}
    }
    }
    // help the gc
    person = null;
    } catch (Exception ignored) {}
    }

    I checked, and the line that causes this to get slower and slower by the iteration is:

    int local_person_version = getPersonVersionByID(person.getID());

    Here is the code of the function getPersonByID:

    public int getPersonVersionByID(String id) {
    try {
    Person person = new Person();
    ObjectSet persons = m_pm.find(Person.class, null, null);
    if (null == persons) {
    return 0;
    }
    for (int i = 0; i < persons.size(); i++) {
    persons.get(i, person);
    if (id.equals(person.getID())) {
    return person.getVersion();
    }
    }
    }
    catch (Exception ignored) {}
    return 0;
    }

    All exception are ignored for the sake of this example, but not in my real code (and non are being thrown).

    Anyone has a clue what could be done in order to improve the performance of this? It takes 15 minutes for the MIDlet to go over 100 "Persons" where as it finishes the first 10 in 5 seconds..

    Thanks!

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: Floggy Performance Issue

    public int getPersonVersionByID(String id) {
    try {
    Person person = new Person();
    I see problem here, when getPersonVersionByID() is called many times, every time you are creating a new object of Person(). Try to re-use this object.
    Please do a memory monitoring of your process, the performance slow down may be coming from over utilization of heap memory which is forcing the VM to call GC again and again.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  3. #3
    Regular Contributor
    Join Date
    Jan 2010
    Posts
    52

    Re: Floggy Performance Issue

    Quote Originally Posted by im2amit View Post
    I see problem here, when getPersonVersionByID() is called many times, every time you are creating a new object of Person(). Try to re-use this object.
    Please do a memory monitoring of your process, the performance slow down may be coming from over utilization of heap memory which is forcing the VM to call GC again and again.
    Hey,

    Thanks for the reply. How do I do a memory monitor of my process? I am not familiar with that.

    Thanks!

  4. #4
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: Floggy Performance Issue

    How do I do a memory monitor of my process? I am not familiar with that
    You can run the memory monitor with the emulator or try don device debugging and writing the free available heap memory in the log file.

    Which device you are testing this on ?
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

Similar Threads

  1. Performance problem on Symbian
    By Ikipou in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2010-02-02, 20:02
  2. Nokia 6300 Bluetooth Connectivity Issue
    By flar74 in forum Bluetooth Technology
    Replies: 1
    Last Post: 2008-04-03, 20:19
  3. Realtime Fishing LBS Content's becoming a Hot Issue.
    By viva99kim in forum News and Announcements
    Replies: 1
    Last Post: 2008-02-29, 23:49
  4. Cba issue in Landscape Mode
    By bharatuppal in forum Symbian User Interface
    Replies: 0
    Last Post: 2007-11-13, 15:03
  5. Performance issue
    By calleandersson in forum Mobile Java General
    Replies: 1
    Last Post: 2005-07-09, 13:32

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×