Here's the code:
@interface myClass {
std::vector<float> myVector
}
@end
It's leaking according to instruments. Here's the stack trace:
1 libstdc++.6.dylib operator new(unsigned long)
2 __gnu_cxx::new_allocator<float>::allocate(unsigned long, void const*)
3 std::_Vector_base<float, std::allocator<float> >::_M_allocate(unsigned long)
I'm guessing I should be allocating the vector on the heap, but I still don't understand why this occurs. It's also possible I'm failing to dealloc the class properly.
Check if your class's dealloc is called. It seems to be the one way that can call leak in this case. And just one question: why don't you use native objective-c containers? You well need to store your floats in NSNumbers, but you will be able to use standard retain/release memory management model for all of your instances.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.