|
Boost Users : |
From: Paul Giaccone (paulg_at_[hidden])
Date: 2007-04-20 05:29:02
Michael Fawcett wrote:
> On 4/19/07, Paul Giaccone <paulg_at_[hidden]> wrote:
>
>> Paul Giaccone wrote:
>>
>> Hm, that made no difference... Maya is still hanging with a segmentation
>> fault when delete() is being called (not by me, incidentally) after 24
>> out of 48 frames have been processed, as if it is deciding it doesn't
>> want the node after that length of time. It still works fine in Windows.
>>
>
> I don't think it has anything to do with Boost. I specifically
> remember using smart_ptrs (and other Boost libraries) in conjunction
> with the Maya SDK, but I no longer have Maya installed so I can't code
> up a quick test for you.
>
> I imagine the problem is with the usage of the smart_ptrs, or lies
> elsewhere. Can you maybe post a small sample of your usage?
>
Hm, it's hard to cut it down to anything small, but I'll try to give
just the minimum here. Here's the creation of the node:
void* MyNode::creator(void)
{
return new MyNode();
}
Here's the constructor:
MyNode::MyNode(void) : success(false), error_message(""), info(0)
{
position.second.resize(NumPositionParameters);
orientation.reset(new double[NumOrientationParameters]);
previous_position_parameter.resize(NumPositionParameters);
for (unsigned int parameter = 0; parameter !=
NumPositionParameters; ++parameter)
{
previous_position_parameter[parameter] = 0.0;
}
}
where the following are declared in the header file (as well as lots of
other non-pointer variables):
boost::scoped_ptr<Info> info;
std::pair<double, std::valarray<double> > position;
boost::shared_array<double> orientation;
std::valarray<double> previous_position_parameter;
Info is a class that contains further shared_arrays of simple types. The
variable info is initialised in MyNode::initialize() because the sizes
of the arrays are not known until that point.
MyNode::compute() calls a stand-alone function, passing in some of the
above variables. Within this function are the following definitions:
MyModel model;
simplex<MyModel> simplex_method(model);
The class "simplex" requires the classes it makes use of to have a
default constructor that does not allocate any memory for objects
pointed to by class members. The memory is allocated when the simplex
class calls operator=, which I have defined for each class that simplex
uses. I have used smart pointers and memory is allocated using reset()
in each operator=() function.
The only destructor I have is for the MyNode class, which resizes the
valarrays to 0, although these only contain doubles, so there isn't
really anything to free.
I don't know how helpful this is, but thanks for anything you might spot
that I have not.
Paul
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net