Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS: Memory usage #1278

Open
Peach82 opened this issue May 8, 2024 · 3 comments
Open

iOS: Memory usage #1278

Peach82 opened this issue May 8, 2024 · 3 comments

Comments

@Peach82
Copy link

Peach82 commented May 8, 2024

Hello, I'm trying to user RTABMap inside an iOS application but I have some memory problems.
I added the ViewController in a navigationViewController and it works as expected.
When I start a new scan the memory usage is about 200MB, the problem is the second scan: when I pop the ViewController with the scanner and then add it back to the navigation stack the initial memory usage is very high (I ended a scan with an M1 iPad Pro at about 1300MB of memory usage, and the next scan started with a memory usage of about 1000MB)
Is there a way to free the memory after popping the RTABMap ViewController from the navigation stack?
Thank You

@matlabbe
Copy link
Member

Unless there is a memory leak, the memory should be reclaimed when starting a new scan. However if on iOS it is like on unix system, the RAM may appear not released though it is. For example, if the second scan is smaller than the first one, the memory usage may remain at 1000 after mapping.

@Peach82
Copy link
Author

Peach82 commented May 15, 2024

Thank You for the reply.
I tried to run the application in Xcode Instruments, and when I pop the scan view controller from the navigation stack I have 9 memory leaks. This is the leaks output, don't know if can be of any help

Leaked Object	Count	Address	Size	Responsible Library	Responsible Frame
Malloc 64 Bytes		2	< multiple >	128 Bytes	RTABMapApp	rtabmap::Memory::Memory(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>> const&)
Malloc 32 Bytes		2	< multiple >	64 Bytes	RTABMapApp	cv::aruco::DetectorParameters::create()
Malloc 32 Bytes		2	< multiple >	64 Bytes	RTABMapApp	rtabmap::Rtabmap::parseParameters(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>> const&)
Malloc 32 Bytes		2	< multiple >	64 Bytes	RTABMapApp	cv::Ptr<cv::aruco::Dictionary> cv::makePtr<cv::aruco::Dictionary, cv::aruco::Dictionary>(cv::aruco::Dictionary const&)
Malloc 208 Bytes	2	< multiple >	416 Bytes	RTABMapApp	rtabmap::Rtabmap::parseParameters(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>> const&)
Malloc 176 Bytes	2	< multiple >	352 Bytes	RTABMapApp	cv::aruco::DetectorParameters::create()
Malloc 144 Bytes	2	< multiple >	288 Bytes	RTABMapApp	void std::__1::vector<double, std::__1::allocator<double>>::__assign_with_size[abi:ue170006]<double*, double*>(double*, double*, long)
Malloc 128 Bytes	2	< multiple >	256 Bytes	RTABMapApp	rtabmap::Optimizer::create(rtabmap::Optimizer::Type, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>> const&)
Malloc 112 Bytes	2	< multiple >	224 Bytes	RTABMapApp	cv::Ptr<cv::aruco::Dictionary> cv::makePtr<cv::aruco::Dictionary, cv::aruco::Dictionary>(cv::aruco::Dictionary const&)

@matlabbe
Copy link
Member

Total of bytes is around 1.5MB. Most of these functions are called only once, so maybe not the source of the huge memory usage you are seeing. A cv::Ptr is a smart pointer, not sure it shows up as a "leak".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants