当前位置:网站首页>Gbase 8s UDR memory management_ 02_ mi_ dalloc
Gbase 8s UDR memory management_ 02_ mi_ dalloc
2022-07-25 19:29:00 【Eight delicacies tofu】
function mi_dalloc The role of is : Allocate the specified amount of memory within the specified memory duration , And return a pointer to the allocated block .
1. grammar
void *mi_dalloc (size, duration)
mi_integer size;
MI_MEMORY_DURATION duration;
size Number of bytes to allocate .
duration
Specifies the value of the memory duration of the user memory to be allocated . The valid values of duration are as follows :
value | meaning |
PER_ROUTINE | stay UDR During an iteration of |
PER_COMMAND | The duration of executing the current subquery |
PER_STATEMENT (Deprecated) | At present SQL The duration of the statement |
PER_STMT_EXEC | At present SQL During the execution of the statement |
PER_STMT_PREP | In the current preparation SQL The duration of the statement |
PER_TRANSACTION (Advanced) | During a transaction |
PER_SESSION (Advanced) | During the current client session |
PER_SYSTEM (Advanced) | During database server execution |
On the client side LIBMI Valid in application ? | Valid in user-defined routines ? |
yes ( however , Application ignores memory duration ) | yes |
2. usage
mi_dalloc() The function is a DataBlade API The module allocates size bytes of shared memory .mi_dalloc() Function is a constructor for user memory . The behavior of this function is similar to mi_alloc() Exactly the same , It's just mi_dalloc() Allows you to explicitly specify the memory duration when allocating .
The server
about C UDR Most memory allocations in ,duration The parameter must be one of the following public memory duration constants :
PER_ROUTINE( or PER_FUNCTION)
Appoint PER_ROUTINE, The database server will be in UDR Free allocated memory on return .
PER_COMMAND
Appoint PER_COMMAND, The database server will free memory when the subquery is completed .
PER_STMT_EXEC
Appoint PER_STMT_EXEC, The database server will be in SQL Release memory when the statement is completed .
PER_STMT_PREP
Appoint PER_STMT_PREP, The database server will be ready SQL Release memory when the statement terminates .
Tips : Only when the regular memory duration cannot safely perform the tasks that need to be completed , Only then C UDR Advanced memory duration used in . These advanced memories last a long time , It will increase the possibility of memory leakage .
stay C UDR in , When an exception is thrown , The database server is automatically released through mi_dalloc() Allocated memory .
a key : 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 , Routine cannot free memory .
When there is no need for mi_dalloc() When allocating memory ,UDR have access to mi_free() Explicitly release mi_dalloc() Allocated memory .
client
On the client side LIBMI In the application ,mi_dalloc() How it works and malloc() Exactly the same :
The storage is allocated on the heap of the client process . however , The database server will not automatically free this memory . therefore , client LIBMI Application must use mi_free() Function explicitly releases mi_dalloc() All assignments made . The client LIBMI Application ignores memory duration .
In the callback function , call mi_dalloc() request PER_COMMAND The duration of will return NULL. therefore , The callback function must call mi_dalloc(), Its duration is PER_ROUTINE.
mi_dalloc() Function returns a pointer to the newly allocated memory . Convert this pointer to match the structure of the user-defined buffer or structure you allocated .
3. return value
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_dalloc() The function will not throw when encountering a runtime error MI_Exception event . therefore , This function does not cause the callback to be called .
边栏推荐
- Improvement of wechat applet 29 hot search list ②
- C# 合并集合
- 聊聊接口性能优化的11个小技巧
- Why learn service grid istio
- [iniparser] simple use of the project configuration tool iniparser
- 基于PHP的中非南南合作信息交流平台网站建设
- How to analyze qiime2 after obtaining picrust2 results
- telnet安装以及telnet(密码正确)无法登录!
- 阿姆利塔工程学院|用于情感分析的方面术语提取中优化采样的强化主动学习方法
- Eve - 0day Threat Intelligence
猜你喜欢
随机推荐
How to analyze qiime2 after obtaining picrust2 results
i3-status 配置
授权无线通信标准
加州大学|用于未指定环境的可行对抗鲁棒强化学习
Talk about 11 tips for interface performance optimization
Juzhi cloud computing opens a new era to the "proprietary cloud" of Youfu network
Istio exposes applications to the Internet
Monitor MySQL based on MySQL exporter
虹科分享|如何解决勒索软件安全漏洞
Day7:有序二叉树(二叉搜索树)
聊聊sql优化的15个小技巧
小程序毕设作品之微信校园维修报修小程序毕业设计成品(2)小程序功能
GBASE 8s UDR内存管理_03_mi_realloc
Amrita Institute of Engineering | reinforcement active learning method for optimizing sampling in terms extraction of emotional analysis
KCon 2022 亮点及议程大揭秘!
微信小程序 29 热搜榜的完善②
SDL text display
【DETR用于3D目标检测】DETR3D: 3D Object Detection from Multi-view Images via 3D-to-2D Queries
Sccm2012r2 network deployment reinstallation system
Small program completion work wechat campus maintenance application small program graduation design finished product (2) small program function









