NX Open Programmer's Guide > Executing NX Open Automation > Unload Options
Unload Options
The Common API defines an entry point (Get Unload Option) that NX automatically calls to determine the desired unload behavior for a loaded executable.
Unload Behavior Options
- Immediately — NX unloads the executable as soon as the application returns control to NX. Typically used during testing (see "Development Cycle Considerations"). Not recommended for UI applications, since a UI app often starts its UI on another thread and returns from the main entry point while the UI thread is still running — NX could try to unload the application while it's still active.
- Explicitly — the user interactively unloads via File tab → Utilities → Unload Shared Image.
- At Termination — the executable is not unloaded until the NX session ends. Typically used for released applications; improves performance since the app loads only once no matter how many times it runs.
If the Get Unload Option entry point is not found, NX defaults to At Termination.
Exceptions and Notes
- Unload options do not eliminate the need to restart NX after the application corrupts the data model or halts the NX process. It's not always obvious which failures require a restart — best practice is to restart NX after severe errors or unexplained results.
- In multi-threaded applications where one executable references another, you must ensure all referencing executables are halted and unloaded together, or a still-loaded executable may hold invalid references to an unloaded one and fail.
- Capabilities that establish references from NX into your application (e.g., a User Defined Object providing a model-update callback) mean you cannot use Immediate or Explicit unload without also removing all such references — otherwise NX fails accessing invalid references.
- Some development environments won't allow rebuilding an executable that NX still has loaded/in-use. Using Immediate removes the need to exit NX before relinking.
- Unloading an executable releases its licenses and triggers garbage collection.
- If your application registers any callbacks, you cannot use Immediate or Explicit (unload via dialog) — you must use At Termination.
Language-Specific Details
NX Open for C++
- Entry Point:
extern int ufusr_ask_unload( void ) - Return values:
UF_UNLOAD_IMMEDIATELY,UF_UNLOAD_SEL_DIALOG(Explicitly),UF_UNLOAD_UG_TERMINATE(At Termination) — defined in<NX install directory>\UGOPEN\uf_ugopenint.h.
extern int ufusr_ask_unload( void )
{
return( UF_UNLOAD_IMMEDIATELY );
}
Note: if the application registers Part Callbacks or UDO callbacks, you must use UF_UNLOAD_UG_TERMINATE.
NX Open for .NET
- Entry Point:
Public Shared Function GetUnloadOption(ByVal arg As String) As Integer(the string argument is unused). - Return values:
Session.LibraryUnloadOption.Immediately,.Explicitly,.AtTermination
Public Shared Function GetUnloadOption(ByVal arg As String) As Integer
Return Session.LibraryUnloadOption.Immediately
End Function
Note: if registering Part/UDO callbacks, must use Session.LibraryUnloadOption.AtTermination.
NX Open for Java
- Entry Point:
static int getUnloadOption() - Return values:
BaseSession.LibraryUnloadOption.IMMEDIATELY,.EXPLICITLY,.AT_TERMINATION
public static int getUnloadOption()
{
return BaseSession.LibraryUnloadOption.IMMEDIATELY;
}
Note: if registering Part/UDO callbacks, must use AT_TERMINATION.
Related Topics
- Execution Overview
- Execution Modes
- Environment Variables
- Application Directory Structure
- How to Execute the Open API
Source: https://docs.sw.siemens.com/en-US/doc/209349590/PL20220512394070742.nxopen_prog_guide/unload_options · retrieved Tue Jul 07 2026 00:00:00 GMT+0000 (Coordinated Universal Time)