Good day. There is something like this:
typedef std::map< unsigned int, Signal > SMap; void thread_proc( ) { try { for( ; ; ) { std::vector< SMap > signals; /// { boost::mutex::scoped_lock lock( m_mutex ); m_signalMaps.swap( signals ); } BOOST_FOREACH( const auto& signal, signals ) HandleSignalMaps( signal ); } //Далее будет указан дизассемблированный код этого участка программы } catch( const boost::thread_interrupted& ) { } }
Trying to watch his disassembled version. I noticed the following fact: In Release and Debug, the code is distinguished by calling delete.
Release:
rcx,qword ptr [signals] 000007FECFF71902 test rcx,rcx 000007FECFF71905 je thread_proc+1CBh (07FECFF7191Bh) 000007FECFF71907 mov rdx,qword ptr [rsp+30h] 000007FECFF7190C call std::vector<std::map<unsigned int,Signal,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,Signal> > >,std::allocator<std::map<unsigned int,Signal,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,Signal> > > > >::_Destroy (07FECFF71BF0h) 000007FECFF71911 mov rcx,qword ptr [signals] 000007FECFF71916 call operator delete (07FECFFBCDF4h) // Вот этот оператор 000007FECFF7191B mov qword ptr [signals],r12 000007FECFF71920 mov qword ptr [rsp+30h],r12 000007FECFF71925 mov qword ptr [rsp+38h],r12 000007FECFF7192A jmp thread_proc+40h (07FECFF71790h) Debug:
000007FECCC44A09 lea rcx,[rsp+28h] 000007FECCC44A0E call std::vector<std::map<unsigned int,Signal,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,Signal> > >,std::allocator<std::map<unsigned int,Signal,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,Signal> > > > >::~vector<std::map<unsigned int,Signal,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,Signal> > >,std::allocator<std::map<unsigned int,Signal,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,Signal> > > > > (07FECCB06226h) 000007FECCC44A13 jmp thread_proc+30h (07FECCC44510h) I understand, in the release delete, it tries to delete the local vector 'signals'. But why is this not in Debug? And unless local variables are deleted call delete? I assumed there would be a pop call, since memory should have been allocated on the stack. Explain, please, where I am mistaken in reasoning.