# ReleaseExternalModule

int ReleaseExternalModule (int moduleID);

## Purpose

Decreases the reference count for a module loaded using LoadExternalModule or LoadExternalModuleEx.

When you call LoadExternalModule successfully on a module, the module reference count increments by one. When you call ReleaseExternalModule, the module reference count decrements by one.

If the reference count decrements to zero, the module ID is invalidated and you cannot access the module through GetExternalModuleAddr or RunExternalModule. If, in addition, the module file is not in the project and not loaded as an instrument, ReleaseExternalModule removes the external module from memory.

If you want to unload the module regardless of the reference count, call UnloadExternalModule rather than ReleaseExternalModule. Use ReleaseExternalModule when multiple calls might have been made to LoadExternalModule on the same module and you do not want to unload the module in case other parts of the application still use it.

## Parameters

Input
Name | Type | Description
moduleID | integer | Module ID you obtain from LoadExternalModule or LoadExternalModuleEx.

## Return Value

Name | Type | Description
status | integer | The result of the operation.
Code | Description
> 0 | Success, but the module was not unloaded. The value indicates the number of remaining references.
0 | Success, and the module was unloaded.
-5 | Module cannot be unloaded because another external module that is currently loaded references it.
-9 | Invalid module ID.