当前位置:网站首页>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 .
边栏推荐
- [wp]ctfshow-web入门信息搜集
- Fearless of high temperature and rainstorm, how can Youfu network protect you from worry?
- Solve the problem that the win10 account has no administrator rights
- Intouch高级报警(报警筛选)
- [applet development] common components and basic usage details
- i3-status 配置
- JS learning notes 17: DOM query exercise
- 二叉树可视化
- Selenium 设置元素等待的三种方式详解
- Talk about 11 tips for interface performance optimization
猜你喜欢

网络数据包多层传输演示

Old wine in new bottles -- sample analysis of recent apt32 (sea Lotus) organizational attacks

Why learn service grid istio

Actual combat of MySQL database design project of online mall system

Talk about 11 tips for interface performance optimization

小程序毕设作品之微信校园维修报修小程序毕业设计成品(1)开发概要
![[wp]ctfshow-web入门信息搜集](/img/22/c2e5cca918800dda9df27272eb9871.png)
[wp]ctfshow-web入门信息搜集

KCon 2022 亮点及议程大揭秘!

高端旗舰投影仪选购指南:当贝X3 Pro、当贝F5观影更沉浸!

Kcon 2022 highlights and agenda revealed!
随机推荐
Dynamic implementation of wechat applet 27 progress bar and static construction of search box and hot search list
平衡二叉树
某公司网络设计与规划
Hash undirected graph visualization
Talk about 11 tips for interface performance optimization
六轴传感器使用学习记录
Youfu force supercomputing provides customized high-performance computing services for customers
帝国CMS7.5仿《问答库》题库问答学习平台网站源码 带手机版
leetcode刷题:动态规划07(不同的二叉搜索树)
安全基础4 ---正则表达式
Imeta | sangerbox: interactive integrated clinical information analysis platform
How many lines of code is appropriate for a function? Clean Code
“未来杯”第二届知识图谱锦标赛正式启动
Global configuration and page configuration of wechat applet development
Actual combat of MySQL database design project of online mall system
Hongmeng - Damiao computing Sketchpad - Introduction
浅谈接口加密
[applet development] detailed explanation of host environment
鸿蒙-大喵计算画板-视频
Security foundation 6 - vulnerability recurrence