---
title: CMCloseProfile
framework: Application Services
role: pseudoSymbol
platforms: []
path: applicationservices/colorsync_manager/1804861-cmcloseprofile
---

# CMCloseProfile

Decrements the reference count for the specified profile reference and, if the reference count reaches 0, frees all private memory and other resources associated with the profile.

## Declaration

```occ
CMError CMCloseProfile (
   CMProfileRef prof
);
```

## Parameters

- `prof`: A profile reference of type [doc://com.apple.documentation/documentation/applicationservices/cmprofileref](applicationservices/cmprofileref.md) that identifies the profile that may need to be closed.

## 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 a call to the [CMOpenProfile](1804853-cmopenprofile.md), [CMNewProfile](1804911-cmnewprofile.md), [CMCopyProfile](1804870-cmcopyprofile.md), or [CWNewLinkProfile](1804915-cwnewlinkprofile.md) functions. Calling the function [CMCloneProfileRef](1804891-cmcloneprofileref.md) increments the count; calling the `CMCloseProfile` function decrements it. The profile remains open as long as the reference count is greater than 0, indicating there is at least one remaining reference to the profile. When the count reaches 0, the ColorSync Manager releases all private memory, files, or resources allocated in association with that profile.

When the ColorSync Manager releases all private memory and resources associated with a profile, any temporary changes your application made to the profile are not saved unless you first call the `CMUpdateProfile` function to update the profile.

When your application passes a copy of a profile reference to an independent task, whether synchronous or asynchronous, it should call the function [CMCloneProfileRef](1804891-cmcloneprofileref.md) to increment the reference count. Both the called task and the caller should call `CMCloseProfile` when finished with the profile reference.

You call `CMCloneProfileRef` after copying a profile reference, but not after duplicating an entire profile (as with the `CMCopyProfile` function).

When your application passes a copy of a profile reference internally, it may not need to call `CMCloneProfileRef`, as long as the application calls `CMCloseProfile` once for the profile.

In your application, make sure that `CMCloseProfile` is called once for each time a profile reference is created or cloned. Otherwise, the private memory and resources associated with the profile reference may not be properly freed, or an application may attempt to use a profile reference that is no longer valid.

If you create a new profile by calling the `CMNewProfile` function, the profile is saved to disk when you call the `CMCloseProfile` function unless you specified `NULL` as the profile location when you created the profile.

To save changes to a profile before closing it, use the function [CMUpdateProfile](1804864-cmupdateprofile.md). 

## See Also

### Accessing Profiles

- [CMOpenProfile](1804853-cmopenprofile.md)
- [CMValidateProfile](1804856-cmvalidateprofile.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)
- [CMGetProfileRefCount](1804894-cmgetprofilerefcount.md)
- [CMFlattenProfile](1804897-cmflattenprofile.md)
- [NCMUnflattenProfile](1804901-ncmunflattenprofile.md)
