[Trilinos-Users] Teuchos::RCP behavior

Bartlett, Roscoe A. bartlettra at ornl.gov
Fri May 10 08:54:35 MDT 2013


All,

> -----Original Message-----
> From: trilinos-users-bounces at software.sandia.gov [mailto:trilinos-users-
> bounces at software.sandia.gov] On Behalf Of Holger Brandsmeier
> Sent: Friday, May 10, 2013 9:36 AM
> To: Villa Andrea (RSE)
> Cc: trilinos-users at software.sandia.gov
> Subject: Re: [Trilinos-Users] Teuchos::RCP behavior
> 
> Enabling:
> >> -D Teuchos_ENABLE_DEBUG:BOOL=ON
> >> -D Teuchos_ENABLE_DEBUG_RCP_NODE_TRACING:BOOL=ON
> Does not give you an "internal" Debugger. You should use `valgrind`
> for that. If you use an RCP and some other class outside of RCP is
> deleting the underlying object, then trilinos has no way to warn you
> about it. You likely will get an segfault.

[Bartlett, Roscoe A.] 

Good suggestion.  Yes, you can run valgrind in addition to using the Teuchos Memory Management classes in a debug-mode build (but that can get way expensive so it had better be a very fast running program).  Ised together they have a good shot at finding the most memory issues (but not all).  The only way to guarantee no undefined behavior is to banish the use of all C++ pointers and references from you programs, which is nearly impossible.  Using raw C++ references is a good bit safer and needed in many cases.  There is never a need to expose a raw pointer in new code (unless you need to pass to legacy code that uses raw pointers).

Thanks,

-Ross




More information about the Trilinos-Users mailing list