The stub holds a ref to the channel, but every pending call also takes its 
own ref to the channel.  So the channel won't be destroyed until you 
destroy m_pSpeechStub, reset or destroy channel, and complete any calls 
that you started using the stub.

The channel takes a ref to the channel creds and call creds.  You need to 
release the refs you're holding in the shared_ptr variables, but otherwise 
they should be destroyed when the channel is destroyed.

On Wednesday, May 6, 2020 at 8:52:18 AM UTC-7 [email protected] wrote:

> Here is a snippet of our C++ code...
>
> std::shared_ptr<grpc::ChannelCredentials> m_pChanCreds;
> std::shared_ptr<grpc::ChannelCredentials> m_pCreds;
> std::shared_ptr<grpc::CallCredentials> m_pCallCreds;
> std::unique_ptr<Speech::Stub> m_pSpeechStub;
> m_pChanCreds = grpc::SslCredentials(grpc::SslCredentialsOptions());
> m_pCallCreds = grpc::ServiceAccountJWTAccessCredentials(key, 3600);
> m_pCreds = grpc::CompositeChannelCredentials(m_pChanCreds, m_pCallCreds);
>
> auto channel = grpc::CreateChannel(m_strResourceURI, m_pCreds);
> m_pSpeechStub = Speech::NewStub(channel);
> To clean up m_pCallCreds, m_pCreds, channel and m_pSpeechStub, is it 
> sufficient to just set m_pSpeechStub to NULL? 
>
> How long does it take for the channel to be terminated after the stub is 
> set to NULL? Is there anything else we could/should do to terminate and 
> tear down the channel? 
>
> What about the credentials? Anything we need to do to destroy them?
>
> Thanks.
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/f2652564-d39e-4d6c-b3bb-fab75d53d33b%40googlegroups.com.

Reply via email to