---
title: CMGetProfileRefCount
framework: Application Services
role: pseudoSymbol
platforms: []
path: applicationservices/colorsync_manager/1804894-cmgetprofilerefcount
---

# CMGetProfileRefCount

Obtains the current reference count for the specified profile.

## Declaration

```occ
CMError CMGetProfileRefCount (
   CMProfileRef prof,
   long *count
);
```

## Parameters

- `prof`: A profile reference of type [doc://com.apple.documentation/documentation/applicationservices/cmprofileref](applicationservices/cmprofileref.md) to the profile whose reference count is obtained.
- `count`: A pointer to a reference count. On return, the reference count for the specified profile reference.

## Return Value

A `CMError` value. See [Result Codes](../colorsync_manager.md).

## Overview

The ColorSync Manager keeps an internal reference count for each profile reference returned from calls such as [CMOpenProfile](1804853-cmopenprofile.md) or [CMNewProfile](1804911-cmnewprofile.md). Calling the function [CMCloneProfileRef](1804891-cmcloneprofileref.md) increments the count; calling the function [CMCloseProfile](1804861-cmcloseprofile.md) decrements it. The profile remains open as long as the reference count is greater than 0, indicating at least one routine retains a reference to the profile. When the count reaches 0, the ColorSync Manager releases all memory, files, or resources allocated in association with that profile.

An application that manages profiles closely can call the `CMGetProfileRefCount` function to obtain the reference count for a profile reference, then perform special handling if necessary, based on the reference count.

To copy a profile with the function [CMCopyProfile](1804870-cmcopyprofile.md), you must obtain a reference to that profile by either opening the profile or creating it. To open a profile, use the function [CMOpenProfile](1804853-cmopenprofile.md). To create a new profile, use the function [CMNewProfile](1804911-cmnewprofile.md). As an alternative to using the `CMCopyProfile` function to duplicate an entire profile, you can use the same profile reference more than once. To do so, you call the function [CMCloneProfileRef](1804891-cmcloneprofileref.md) to increment the reference count for the reference each time you reuse it. Calling the `CMCloneProfileRef` function increments the count; calling the function [CMCloseProfile](1804861-cmcloseprofile.md) decrements it. The profile remains open as long as the reference count is greater than 0, indicating at least one routine retains a reference to the profile. 

## See Also

### Accessing Profiles

- [CMOpenProfile](1804853-cmopenprofile.md)
- [CMValidateProfile](1804856-cmvalidateprofile.md)
- [CMCloseProfile](1804861-cmcloseprofile.md)
- [CMUpdateProfile](1804864-cmupdateprofile.md)
- [CMCopyProfile](1804870-cmcopyprofile.md)
- [CMProfileModified](1804872-cmprofilemodified.md)
- [CMGetProfileMD5](1804876-cmgetprofilemd5.md)
- [CMGetProfileHeader](1804879-cmgetprofileheader.md)
- [CMSetProfileHeader](1804882-cmsetprofileheader.md)
- [CMGetProfileLocation](1804885-cmgetprofilelocation.md)
- [NCMGetProfileLocation](1804889-ncmgetprofilelocation.md)
- [CMCloneProfileRef](1804891-cmcloneprofileref.md)
- [CMFlattenProfile](1804897-cmflattenprofile.md)
- [NCMUnflattenProfile](1804901-ncmunflattenprofile.md)
