Memory usage for objects with shared tabled data

Posts   
 
    
rracer99
User
Posts: 58
Joined: 11-Mar-2007
# Posted on: 28-Aug-2007 07:02:32   

Hello,

We have a scenario where we need to keep a bunch of objects in Cache with a structure like this (Adapter):

for example, tables such as:

client -> param (param_name_id, param_name_value) -> param_name (param_name_id, param_name)

So if we have a large ClientEntityCollection in memory:

client -> param (-> param_name "some param name 1") param (-> param_name "some param name 2") param (-> param_name "some param name 3")

client -> param (-> param_name "some param name 2") param (-> param_name "some param name 3")

etc.

There will be many copies of the same param name records throughout the EntityCollection. This is a simple example, but we are wondering if we can keep a quite large collection in the server cache. The root Entity in the collection will references many sub-entities used throughout the collection by other root-entities.

What are the memory implications?

Does LLBLGen keep separate copies of this data in memory or perhaps use references to avoid duplication of data?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 28-Aug-2007 11:12:40   

client -> param (param_name_id, param_name_value) -> param_name (param_name_id, param_name)

So if we have a large ClientEntityCollection in memory:

client -> param (-> param_name "some param name 1") param (-> param_name "some param name 2") param (-> param_name "some param name 3")

client -> param (-> param_name "some param name 2") param (-> param_name "some param name 3")

The example is not clear for me.

But if you are asking about keeping unique instances in memory rather than duplicates. Then maybe you should be using a Context. Please refer to the LLBLGen Pro manual's section "Using the generated code -> Adapter/SelfServicing -> Using the context"

rracer99
User
Posts: 58
Joined: 11-Mar-2007
# Posted on: 28-Aug-2007 21:19:17   

For example,

3 tables (project, client, client_contacts)

In code we have an EntityCollection of project objects:

projectA -> client1 -> client contacts for client 1 projectB -> client1 -> client contacts for client 1 projectC -> client1 -> client contacts for client 1 projectD -> client1 -> client contacts for client 1

There is a lot of duplicate data.

Does LLBLGen treat all of this as separate instances or references to save memory?

In our case we would prefer "references" to save memory as it will be used in a data cache type role.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 29-Aug-2007 10:54:22   

Does LLBLGen treat all of this as separate instances or references to save memory?

Separate instances unless you use a Context.