当前位置:网站首页>Gbase 8s UDR memory management_ 01_ mi_ alloc
Gbase 8s UDR memory management_ 01_ mi_ alloc
2022-07-25 19:29:00 【Eight delicacies tofu】
function mi_alloc() The role of is : Allocate a user memory block of a specified size , And return a pointer to the block .
1. grammar
void *mi_alloc(size)
mi_integer size;
size Number of bytes to allocate .
On the client side LIBMI Valid in application ? | Valid in user-defined routines ? |
yes | yes |
2. usage
function mi_alloc() The role of is : by DataBlade API The number of bytes of user memory allocated by the module .mi_alloc() Function is the constructor of user memory .
Server side : from C From the perspective of user-defined routines , The behavior of this function is similar to malloc() system call , Only the database server can be recycled mi_alloc() Allocated memory . The delta function is going to be : Allocate memory for the current memory duration . By default , The current memory duration is PER_ROUTINE. Use PER_ROUTINE The duration of the , The database server is C UDR Release the allocated memory after returning .
Except callback routines , You can change the memory duration in any of the following ways :
1, Use mi_dalloc() instead of mi_alloc() To allocate memory .
mi_dalloc() The function works the same way as mi_alloc() identical , And provide the option of specifying the duration .
2, Calling mi_alloc() Before , First call mi_switch_mem_duration().
function mi_switch_mem_duration() Used to change the current memory duration of all subsequent memory allocations .
stay UDR Routine , When an exception is thrown , The database server is automatically released mi_alloc() Allocated memory .
Important note : stay C UDR in , Use DataBlade API Memory management function to allocate memory . Use DataBlade API The memory management function can ensure that the database server can automatically release memory , Especially in the case of return value or exception , Otherwise, the routine will not be able to free memory .
client : On the client side LIBMI In the application ,mi_alloc() Working mode and malloc() Exactly the same : It allocates storage on the heap of the client process . The database server does not perform any automatic storage retrieval . client LIBMI Application must use mi_free() To explicitly release mi_alloc() All assignments made . client LIBMI Application ignores memory duration .
client LIBMI Applications can use DataBlade API Memory management function or system memory management function ( Such as malloc()).
function mi_alloc() The role of is : Returns a pointer to the newly allocated user memory . Cast this pointer to match the user-defined buffer or allocated structure .DataBlade API Modules can be used mi_free() To release the mi_alloc() Allocated memory ( When the memory is no longer needed ).
3. Return value
One void The pointer .
Pointer to newly allocated memory . Cast this pointer to match the user-defined buffer or structure for which memory is allocated .
NULL
Function cannot allocate memory .
mi_alloc() The function will not raise... When encountering a runtime error MI_Exception event . therefore , It does not cause callbacks to be called .
边栏推荐
- 小程序毕设作品之微信校园维修报修小程序毕业设计成品(3)后台功能
- University of California | feasible confrontation robust reinforcement learning for unspecified environments
- 授权无线通信标准
- NPM semantic version control, solution console prop being mutated: "placement" error
- Selenium 设置元素等待的三种方式详解
- 小程序毕设作品之微信校园维修报修小程序毕业设计成品(6)开题答辩PPT
- 高效生成接口文档好方法
- Nezha d1-h test microbench
- Openresty Lua resty mlcache multi-level cache
- [Detr for 3D object detection] detr3d: 3D object detection from multi view images via 3D-to-2D queries
猜你喜欢

Have you ever seen this kind of dynamic programming -- the stock problem of state machine dynamic programming (Part 1)

Talk about 15 tips of SQL optimization

阿里云免费SSL证书申请详细流程

授权无线通信标准

微信小程序 27 进度条的动态实现和搜索框、热搜榜的静态搭建

Day7:有序二叉树(二叉搜索树)

小程序毕设作品之微信校园维修报修小程序毕业设计成品(5)任务书

Pymoo learning (6): termination conditions

微信小程序10-微搭模板

基于PHP的中非南南合作信息交流平台网站建设
随机推荐
Code sharing of social chat platform developed by dating website (III)
Intouch高级报警(报警筛选)
[server data recovery] a data recovery case of a brand ProLiant server raid paralysis, database file loss, and database file backup damage
前夕 - 0day威胁情报
QIIME2得到PICRUSt2结果后如何分析
Internal network planning and design of Yingcheng hospital
平衡二叉树
手机端触摸图片slider轮播插件photoswipe.js
Leetcode skimming: dynamic programming 07 (different binary search trees)
Hash undirected graph visualization
Scala基础【集合01】
Improvement of wechat applet 28 hot search list ①
鸿蒙-大喵计算画板-简介
Network data request for wechat applet development
一个函数中写多少行代码比较合适呢? 代码整洁之道
Fearless of high temperature and rainstorm, how can Youfu network protect you from worry?
ERROR: role “admin“ cannot be dropped because some objects depend on itDETAIL:
The second "future Cup" knowledge map championship was officially launched
Selenium运行慢 - 通过设置selenium加载策略加快运行速度
An idea of solving div adapting to screen