---
title: aclrtMemRetainAllocationHandle
description: "| 产品 | 是否支持 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/runtimeapi/aclcppdevg_03_2118.html
sourcePath: /source/zh/canncommercial/900/API/runtimeapi/aclcppdevg_03_2118.html
indexId: 905c1853e37891d92bf2a5f5c1f44fd37e89872606822ec84fbb228cc1684df568
---
# aclrtMemRetainAllocationHandle

#### 产品支持情况

| 产品 | 是否支持 |
| --- | --- |
| Atlas 350 加速卡 | √ |
| Atlas A3 训练系列产品 / Atlas A3 推理系列产品 | √ |
| Atlas A2 训练系列产品 / Atlas A2 推理系列产品 | √ |
| Atlas 200I/500 A2 推理产品 | √ |
| Atlas 推理系列产品 | √ |
| Atlas 训练系列产品 | √ |


#### 功能说明

根据虚拟内存地址获取物理内存信息的handle。

若多次调用本接口，则需相应地调用相同次数的aclrtFreePhysical来释放物理内存handle。

若调用接口时返回ACL_ERROR_RT_FEATURE_NOT_SUPPORT，这表示底层驱动不支持该特性，需将驱动包升级到26.0.RC1或更高版本。您可以单击Link(https://www.hiascend.com/hardware/firmware-drivers/commercial)，在“固件与驱动”页面下载对应版本的驱动安装包，并参照其文档进行安装和升级。


#### 函数原型

```
aclError aclrtMemRetainAllocationHandle(void* virPtr, aclrtDrvMemHandle *handle)
```


#### 参数说明

| 参数名 | 输入/输出 | 说明 |
| --- | --- | --- |
| virPtr | 输入 | “已分配的虚拟内存地址的指针”的指针。 必须与aclrtMapMem接口的virPtr地址相同。 |
| handle | 输出 | 存放物理内存信息的handle。类型定义请参见aclrtDrvMemHandle。 |


#### 返回值说明

返回0表示成功，返回其他值表示失败，请参见aclError。


#### 约束说明

Atlas 200I/500 A2 推理产品 上，Ascend RC形态不支持调用本接口。
