Re: deallocation problem or conflict ?


Thanks for the help, the code now seems to work but I have noticed that
one of the problems depends on the order in which I allocate the
"retval" and the "rdimg". Allocating "rdimg" first and then "retval"
causes a segmentation violation when freeing "rdimg" at the end of the

retval = EzxS_EzxRdrImgObj__alloc( );
rdimg = readfile( "cermet", NULL, 0, 0 );
if( !rdimg )
	fprintf( stderr, "Failed to allocate image\n" );

I use the octet sequence buffer to fill the image in the client for
display, so I free it in the client after copying the content to a
"guchar" array, so it cannot be released whne the server returns the
structure to the client.

I use the "CORBA_foo" casts in the code, because I have learned from
past experiences that not casting values may some day cause trouble
which at that time may be hard to find. For the same reason I usualy
initialize all values when declaring them, so the don't keep haning
around "undefined". My programming style is more towards stability and
reliabilty than towards speed as I do not like customers complaining
from unstable software, it costs too much money to a small company to
deal with customer complaints.

Thanks to the ORBit software, more than 10 years of software development
in automated micrscopy develop into a distributed system. My ultimate
goal is to develop our system into something capable to do for Cytomics
what Celera did for DNA sequencing and fill an entire room with automaed
"High Information Content Screening" systems ;-) By using CORBA we can
manage the instruments and analysis servers from a distance and with any
"client" system we want, independent form the client operating system.
The "server" will always run on Unix for its speed and stability of

Best regards,

Peter Van Osta

Michael Meeks wrote:
> Hi Peter,
> On Mon, 2003-05-05 at 16:21, Peter Van Osta wrote:
> > I am also puzzled
> > how to free the return value "EzxRdrImgObj" on the client side after the
> > transfer of the image data to the client.
>         All ORB allocated values; and values returned into the ORB - have to be
> allocated (and thus freed) using the ORB allocators (obviously). Thus
> you should use CORBA_free.
> >       retval->type = ( CORBA_short )ImageTypeIdent( rdimg );
> >       retval->width = ( CORBA_long )ImageWidth( rdimg );
> >       retval->height = ( CORBA_long )ImageHeight( rdimg );
> >       retval->depth = ( CORBA_long )ImageDepth( rdimg );
> >       retval->slice = 0;
>         Do you really need those CORBA_foo casts ? the rest of the code looks
> fine except for:
> >       retval->data._release = ( CORBA_boolean )FALSE;
> >       CORBA_sequence_set_release( &( retval->data ), FALSE );
>         In fact you want to set release TRUE on that sequence, just once;so I'd
> use the CORBA_sequence_set_ method for that;
>         It seems that you don't free your rdimage in the code you pasted; but
> you leak the sequence. If you are still having problems you can't
> understand, I would strongly suggest building 'valgrind' and running
> that (--alignment=8) on your code.
>         HTH,
>                 Michael.
> --
>  <><, Pseudo Engineer, itinerant idiot

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]