DynamicData

7 posts / 0 new
Last post
Offline
Last seen: 10 years 8 months ago
Joined: 04/25/2013
Posts: 6
DynamicData

hi everybody,

I want to

 
struct task  {
    long a;
    long b;
    sequence<double> cSeq;
};

struct entity {
    long id;
    long num;
    sequence<task> myTaskSeq;
};

struct myType {
    double speed;
    sequence<entity> myEntity; 
};

but in task struct,the cSeq's length is not sure,even for 0.

it will lead to takeup too much memory.

how can I improve this situation? 

Gerardo Pardo's picture
Offline
Last seen: 14 hours 32 min ago
Joined: 06/02/2010
Posts: 601

Hello,

The IDL you show above will produce erros when you run rtiddsgen on it. Sequences must be always templatized by the element-type. In addition it is possible to specify a maximum element count. If left unespecified the middleware defines a max element count of 100.

I have changed the IDL to the one shown below which can be parsed successfully by rtiddsgen.

struct task  {
    long a;
    long b;
    sequence cSeq;
};
 
struct entity {
    long id;
    long num;
    sequence myTaskSeq;
};
 
struct myType {
    double speed;
    sequence myEntity; 
};

I run rtiddsgen on the IDL above. Then I inserted the following code in the example application:

   int maxSerialized = myTypePlugin_get_serialized_sample_max_size(
            NULL, RTI_FALSE, 0, 0);
    printf("maxSerialized = %d\n", maxSerialized);

When I run this I get a maxSerialized = 4121212 bytes (4.12.MB) . The reason is that if the maximum length of the sequence is unspecified, then the miffleware assumes a size of 100 elements. This may not sound like much, but when you nest a sequnce inside a sequence inside a sequence you are getting a maxsize ~ 100x100x100x side of innermost element. In this case the innermost element is a long (size 4) so we get a number in the order of 4x100x100x100 ~= 4MB

This is just the size of a single elememt. Depending on how you have configured (in terms of resource limits) your DataWriter and DataReader  you well get something like max_samples x  myTypePlugin_get_serialized_sample_max_size(...).  A max_samples of 1000 is not uncommon. If you did that you would get to 4GB of memory...

So this data-type is quote inneficient in terms of memory. Can you explain a little more of what you are trying to do? Khowing this perhaps we can suggest something more efficient way to define the data-types...

Regards,

Gerardo

 

Offline
Last seen: 10 years 8 months ago
Joined: 04/25/2013
Posts: 6

hi Gerardo Pardo,

Sorry, I didn't make it clear.

 I create a nested data structure which has many layers,like the above example. then,i have a mistake.It tell me is too larger,more than 3GB!

In fact,some of these sequences,don't need such a big length.

for exemple,the struct named task,may not have the property named cSeq.or the length of cSeq is very small!

The length   is dynamic.

what can i do for it? thank you very much!

Offline
Last seen: 10 years 8 months ago
Joined: 04/25/2013
Posts: 6

i want to change the length of the sequences dynamic,but i don't know how to do!

Or  you  can give me other advice, will solve my problem.I'm enormously grateful for your help!!!

rip
rip's picture
Offline
Last seen: 14 hours 30 min ago
Joined: 04/06/2012
Posts: 324

Hi

when you create your IDL sequences without giving a count:

sequence<double> cSeq;

the default sequence length is 100.  So you are telling the type system you need a sequence which will hold a maximum of 100 doubles.  This default length is configurable at the command line.

If you give the sequence a value:

sequence<double, 5> cSeq;

You are telling the Type system that at most this cSeq sequence will need to hold 5 doubles.

When the cSeq is serialized, if it is empty, then NO SPACE is sent for that field.  So this is good use of bandwidth.

See

http://community.rti.com/rti-doc/500/ndds.5.0.0/doc/pdf/RTI_CoreLibrariesAndUtilities_UsersManual.html#page_40

http://community.rti.com/rti-doc/500/ndds.5.0.0/doc/pdf/RTI_CoreLibrariesAndUtilities_UsersManual.html#page_74 (section 3.3.1.1)

Offline
Last seen: 10 years 8 months ago
Joined: 04/25/2013
Posts: 6

hi, what you said about the sequences i know.

now  i want to change the length dynamic.

because,the count of the cSeq  may be 5,but may be 500!

If i give the sequence a value:500!

the struct myType will too large more than 3G,becausethe nested structure!!!

felt mortified for this situation!

gianpiero's picture
Offline
Last seen: 2 months 1 week ago
Joined: 06/02/2010
Posts: 177

Hello Christine, 

maybe this post can help: http://community.rti.com/comment/391#comment-391

Best,

 Gianpiero