mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Memory Management : Adjustment and fixes
Add release of several static singleton objects Fix several minor memory leaks
This commit is contained in:
@@ -85,6 +85,7 @@ class RiaGrpcServiceCallback : public RiaGrpcCallbackInterface
|
||||
{
|
||||
public:
|
||||
RiaGrpcServiceCallback( ServiceT* service );
|
||||
~RiaGrpcServiceCallback();
|
||||
|
||||
QString name() const override;
|
||||
const RequestT& request() const;
|
||||
@@ -99,6 +100,14 @@ protected:
|
||||
ReplyT m_reply;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template <typename ServiceT, typename RequestT, typename ReplyT>
|
||||
RiaGrpcServiceCallback<ServiceT, RequestT, ReplyT>::~RiaGrpcServiceCallback()
|
||||
{
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
// Templated gRPC-callback for non-streaming services
|
||||
|
@@ -74,6 +74,7 @@ private:
|
||||
std::unique_ptr<grpc::Server> m_server;
|
||||
std::list<std::shared_ptr<RiaGrpcServiceInterface>> m_services;
|
||||
std::list<RiaGrpcCallbackInterface*> m_unprocessedRequests;
|
||||
std::list<RiaGrpcCallbackInterface*> m_allocatedCallbakcs;
|
||||
std::mutex m_requestMutex;
|
||||
std::thread m_thread;
|
||||
};
|
||||
@@ -217,6 +218,12 @@ void RiaGrpcServerImpl::quit()
|
||||
m_server.reset();
|
||||
m_completionQueue.reset();
|
||||
|
||||
for ( auto c : m_allocatedCallbakcs )
|
||||
{
|
||||
delete c;
|
||||
}
|
||||
m_allocatedCallbakcs.clear();
|
||||
|
||||
// Finally clear services
|
||||
m_services.clear();
|
||||
}
|
||||
@@ -253,6 +260,8 @@ void RiaGrpcServerImpl::process( RiaGrpcCallbackInterface* method )
|
||||
if ( method->callState() == RiaGrpcCallbackInterface::CREATE_HANDLER )
|
||||
{
|
||||
method->createRequestHandler( m_completionQueue.get() );
|
||||
|
||||
m_allocatedCallbakcs.push_back( method );
|
||||
}
|
||||
else if ( method->callState() == RiaGrpcCallbackInterface::INIT_REQUEST_STARTED )
|
||||
{
|
||||
@@ -269,7 +278,11 @@ void RiaGrpcServerImpl::process( RiaGrpcCallbackInterface* method )
|
||||
else
|
||||
{
|
||||
method->onFinishRequest();
|
||||
|
||||
process( method->createNewFromThis() );
|
||||
|
||||
m_allocatedCallbakcs.remove( method );
|
||||
|
||||
delete method;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user