xcode、c++でリークリストを作成するために私がどのように管理したか。したがって、私のiOSプロジェクトには、次のように入力されたカスタムオブジェクトのリストがあります。
int i=0;
while (rawArr->isObject(i)) {
Object::Ptr object = rawArr->getObject(i);
SRComplexType* sr = new SRComplexType(object);
refs.push_front(*sr);
delete sr;
i++;
}
すべてのオブジェクトを削除するデコンストラクターを追加しましたが、ここで何かがリークしているようです。
for(std::list<SRComplexType>::iterator list_iter = refs.begin();
list_iter != refs.end(); list_iter++)
{
list_iter->~SRComplexType();
}
}
SRComplexTypeには次のものが含まれます。
std::string sNo;
std::string sName;
std::string sUrl;
LocationComplexType *sLocation;
sLocation(2つのdoubleといくつかのメソッドのみを含む)は、以下を使用して設定されます。
this->sLocation = new LocationComplexType(locationObject);
LocationComplexTypeのdoubleは、以下を使用して設定されます。
double d;
const char * str = LatRaw.convert<string>().c_str();
sscanf(str, "%*[^0-9]%lf",&d);
free ((void*) str);
this->longitude=d;
機器のリークレポートには次のようなものがあります。
Leaked Object # Address Size Responsible Library Responsible Frame
Malloc < varying sizes > 17 < multiple > 384 Bytes libstdc++.6.dylib std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&)
Malloc 32 Bytes 17 < multiple > 544 Bytes PocoTest2 std::list<SRComplexType, std::allocator<SRComplexType> >::_M_create_node(SRComplexType const&)
Malloc 16 Bytes 1 0x72f2140 16 Bytes PocoTest2 -[ViewController viewDidLoad]
Malloc 3.00 KB 1 0x7c6ca00 3.00 KB libstdc++.6.dylib std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&)
Malloc < varying sizes > 17 < multiple > 560 Bytes libstdc++.6.dylib std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&)
Malloc 32 Bytes 17 < multiple > 544 Bytes libstdc++.6.dylib std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&)