0
2つのベクトルを連結するときに問題が発生します。2つのベクトルを連結するときのstd :: bad_alloc
std::vector<Transform3D> out;
for(double theta = 0; theta <= 2*M_PI ; theta+=1)
{
for(double phi = 0; phi <= M_PI ; phi+=1)
{
double sphere_x = obj_x + r*cos(theta)*sin(phi);
double sphere_y = obj_y + r*sin(theta)*sin(phi);
double sphere_z = obj_z + + r*cos(phi);
Transform3D<> transformation_matrix = transform(obj_x,obj_y,obj_z,sphere_x,sphere_y,sphere_z);
if(0.01<(transformation_matrix.P()[0] - current_x) ||
0.01<transformation_matrix.P()[1] - current_y ||
0.01<transformation_matrix.P()[2] - current_z)
{
cout << "Interpolate: " << endl;
std::vector<Transform3D> transformation_i = invKin_LargeDisplacement(transformation_matrix);
out.insert(out.end(),transformation_i.begin(),transformation_i.end());
}
else
{
cout << "OK" << endl;
out.push_back(transformation_matrix);
}
cout << out.size() << endl;
cout << sizeof(Transform3D<>) << endl;
}
}
out.insert(..)
bad_alloc
を引き起こしているようだが、余分なデータが必要とされています。
Interpolate:
6346700
Interpolate:
12052200
Interpolate:
16476100
Interpolate:
20127501
Interpolate:
26474201
Interpolate:
32239601
Interpolate:
36748301
Interpolate:
40416502
Interpolate:
46763202
Interpolate:
52659402
Interpolate:
57349102
Interpolate:
61053903
Interpolate:
67400603
Interpolate:
73377503
Interpolate:
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted (core dumped)
はまだにできることながら、私は、
bad_alloc
を避けることができますいくつかの方法があります:問題をデバッグしている間、私はループの実行中に、ベクトルの大きさを印刷し、次の出力を得た
補間?
メモリが不足しています。メモリ使用量を調整できる場所を探す時間。 – StoryTeller
私はスワップをまだ使用していません。 – Lamda
7,300万のオブジェクトは、多くのメモリになります。 'sizeof(rw :: math :: Transform3D <>)とは何ですか? – NathanOliver