1. A method for managing memory for an application using a computer, wherein the computer performs actions, including: when one or more threads of a plurality of threads encounters a native code call during the execution of the application in a managed code environment, further actions are performed, including: determining one or more characteristics of the native code call based in part on a target platform for the application; and when the one or more characteristics of the native code call exceeds a defined threshold, updating at least state information for the one or more threads to at least indicate that the one or more threads is executing in an unmanaged code environment; and when a garbage collection event occurs, executing one or more garbage collection actions to manage one or more memory objects that are referenced by one or more threads in the managed code environment that are safe for garbage collection, wherein garbage collection for the safe one or more threads is executed separate from garbage collection actions for the one or more threads that are indicated as executing in the unmanaged code environment.