Forums

Get More Support

Here for you 24/7

learn more
VOD Free SDK

Start Building your Engine Now

Download Now
VOD Extranet

Access to patches, license management,
tech docs and more for existing VOD customers.

Learn More
QueryByExample takes for ages (memory leak)
Last Post 27 Oct 2009 01:36 AM by Fantagon. 5 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Fantagon
New Member
New Member
Posts: 5


--
25 Oct 2009 12:03 PM

    Hello,

     Ik have two objects:

    Albums and Photos.

    The first object (Album) containts:
    private string _name;
    private string _description;
    private DateTime _saveDate;
    private Byte[] _picture;

     The second object (Photo) contains:
    private Album _album;
    private string _name;
    private Byte[] _picture;

     All variables have public properties.
    Storing and getting (QueryByExample) from Albums is perfect.

    But when i want to retreive all photo from an album (create empty photo object en fill Album property with the correct album) the QueryByExample takes for ages and uses up to 1.5 GB memory.

    Am I doing something wrong or...?

    Please help.

    Goran
    Basic Member
    Basic Member
    Posts: 311


    --
    25 Oct 2009 12:40 PM

    Hi!

    Well, you *are* loading all the images from an album into memory - so I guess 1.5GB is what one would expect.

    To retrieve album and related images I would query for album and not vice versa. You might want to remove the _album field from the Photo object. Photos do not need to know which album they are in (also photos might belong to many albums).

    Also please read up on Activation and how it can help you limit the memory usage. Activation can help you create a solution where you receive all photos from an album without receiving the actual images (byte[] _picture).

    Goran 

    Fantagon
    New Member
    New Member
    Posts: 5


    --
    25 Oct 2009 02:33 PM

    I understand that if i have allot of images that the memory usage will be big.
    But it's is only 1 album and 1 photo (both with an image).

    So, the size of memory is not because there are alot of photo's (objects) involved.

     

    Fantagon
    New Member
    New Member
    Posts: 5


    --
    26 Oct 2009 08:15 AM
    Goran:

    Hi!

    Well, you *are* loading all the images from an album into memory - so I guess 1.5GB is what one would expect.

    To retrieve album and related images I would query for album and not vice versa. You might want to remove the _album field from the Photo object. Photos do not need to know which album they are in (also photos might belong to many albums).

    Also please read up on Activation and how it can help you limit the memory usage. Activation can help you create a solution where you receive all photos from an album without receiving the actual images (byte[] _picture).

    Goran 

     

    KICK:

    I understand that if i have allot of images that the memory usage will be big.
    But it's is only 1 album and 1 photo (both with an image).
    So, the size of memory is not because there are alot of photo's (objects) involved.

    And if I use your structure (album contains pictures), when i retreive the albums to show what albums i have, al the pictures will also be gotten from the database. That will be a hughe overload!

    Goran
    Basic Member
    Basic Member
    Posts: 311


    --
    27 Oct 2009 12:27 AM

    Hi!

    This is exactly the scenario where object activation can help. You can build a domain structure and configure db4o in such a way that only the Album object and selected information of Photo objects object get activated. This way you have every Photo object loaded but without having every image of the Photo object loaded. Even better - such list enable you to activate individual Photo objects completely (ie loading the byte array that represents your image from the db).

    Using (simple) activation you could split your Photo object into: 
    Photo object holding fields you want to activate immediately and
    Image object that holds the byte array of image data.

    Setting the class level activation of Photo object will tell db4o to only activate Photo object fields while Image fields (ie the byte array) will be null. Activating Image object manually will load the actual image on demand.

    Using TA you can set up which fields are activated by default and which require manual activation. This enables you to keep your Domain structure but is a bit trickier to implement. 

    I suggest you take the time and read the documentation on Activation. Let me know if you need more help.

    Goran 

    Fantagon
    New Member
    New Member
    Posts: 5


    --
    27 Oct 2009 01:36 AM
    Goran:

    Hi!

    This is exactly the scenario where object activation can help. You can build a domain structure and configure db4o in such a way that only the Album object and selected information of Photo objects object get activated. This way you have every Photo object loaded but without having every image of the Photo object loaded. Even better - such list enable you to activate individual Photo objects completely (ie loading the byte array that represents your image from the db).

    Using (simple) activation you could split your Photo object into: 
    Photo object holding fields you want to activate immediately and
    Image object that holds the byte array of image data.

    Setting the class level activation of Photo object will tell db4o to only activate Photo object fields while Image fields (ie the byte array) will be null. Activating Image object manually will load the actual image on demand.

    Using TA you can set up which fields are activated by default and which require manual activation. This enables you to keep your Domain structure but is a bit trickier to implement. 

    I suggest you take the time and read the documentation on Activation. Let me know if you need more help.

    Goran 

     wow that's nice. I will look into that documentation. Sounds good. Thanks for you anwser

    You are not authorized to post a reply.


    Active Forums 4.3