Skip to content
Prev 24046 / 63421 Next

R/C++/memory leaks

Ernest,
On Feb 25, 2007, at 12:37 PM, Ernest Turro wrote:

            
How do you allow for user interrupts? R doesn't allow interrupts  
while in .C/.Call on purpose, so it's up to your code to handle  
interrupts properly. This also implies that you can use the regular  
methods for error recovery available in your language and handle the  
interrupt yourself by freeing the memory as needed, your code  
shouldn't return to R until it has cleaned everything up ...
This sounds a bit dangerous - how can the separate function know  
about the previous call and the state it was in before the interrupt  
(save for hard-wiring everything into one instance)? Again, the  
crucial part is the interrupt handling in your code - it may fail to  
release some objects...

@Ross [see follow-up]: R_RegisterCFinalizerEx is called on R exit if  
desired (see arguments). However, I don't think this is relevant to  
the discussed issue as a process termination frees all its memory.  
Moreover I don't think Ernest wants to wrap all his classes to R  
objects - we're not talking about the GC here, it is supposed to be C+ 
+ internal issue.

Cheers,
Simon