当前位置:网站首页>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 .
边栏推荐
- Day7:有序二叉树(二叉搜索树)
- 伺服驱动器在机器人上的研究与应用
- Istio exposes applications to the Internet
- 虹科分享|如何解决勒索软件安全漏洞
- Code sharing of social chat platform developed by dating website (III)
- Common misunderstandings caused by a time reporting assistant of Blue Bridge Cup basic questions
- 阿里云免费SSL证书申请详细流程
- An idea of solving div adapting to screen
- leetcode刷题:动态规划07(不同的二叉搜索树)
- Scala基础【集合01】
猜你喜欢

How to analyze qiime2 after obtaining picrust2 results

Wechat campus maintenance and repair applet graduation design finished product (5) assignment of applet completion work

Dynamic implementation of wechat applet 27 progress bar and static construction of search box and hot search list
![[Detr for 3D object detection] 3detr: an end to end transformer model for 3D object detection](/img/22/426bcb8641db5bfe07e8aacf5e8427.png)
[Detr for 3D object detection] 3detr: an end to end transformer model for 3D object detection

TFIDF examples and explanations

微信小程序开发之网络数据请求

虹科分享|如何解决勒索软件安全漏洞

Clip can also do segmentation tasks? The University of Gottingen proposed a model clipseg that uses text and image prompt and can do three segmentation tasks at the same time, squeezing out the clip a

北航等《深度学习事件抽取》文献综述论文,27页pdf阐述当前趋势

Actual combat of MySQL database design project of online mall system
随机推荐
基于PHP的中非南南合作信息交流平台网站建设
Solve the problem that the win10 account has no administrator rights
ERROR: role “admin“ cannot be dropped because some objects depend on itDETAIL:
Pymoo learning (6): termination conditions
Basic practice of Blue Bridge Cup - shape retrieval of matrix (C language)
[wp]ctfshow-web入门信息搜集
Small program completion work wechat campus maintenance application small program graduation design finished product (2) small program function
[applet development] do you know about applet development?
浅谈接口加密
Code sharing of social chat platform developed by dating website (III)
前夕 - 0day威胁情报
NPM semantic version control, solution console prop being mutated: "placement" error
Sccm2012r2 network deployment reinstallation system
Selenium运行慢 - 通过设置selenium加载策略加快运行速度
Scala基础【集合01】
小程序毕设作品之微信校园维修报修小程序毕业设计成品(4)开题报告
485 current acquisition module dam-8041
KCon 2022 亮点及议程大揭秘!
Hongmeng - Damiao computing Sketchpad - VIDEO
鸿蒙-大喵计算画板-视频