- Hands-On System Programming with C++
- Dr. Rian Quinn
- 242字
- 2021-07-02 14:42:28
Memory allocation
Memory is another resource that an application must request using a system call. Most applications are given global and stack memory resources when the application is first executed, along with a small heap of memory that the application can use when calls to functions such as malloc() and free() are made.
If the application only uses the memory that it is initially given in this heap, no extra memory needs to be requested by the application. If, however, heap memory runs out, the application's malloc() or free() engine will have to ask the operating system (via a system call) for more memory.
To do this, the operating system will extend the end of the application by adding more physical memory to the application. The malloc() or free() engine is then able to make use of this additional memory, until more is needed.
On systems with limited RAM, when a request for additional memory is made, the operating system has to take memory from other applications that aren't currently executing. It does this by swapping these applications to disk, an operation that is expensive to perform.
For this reason, on resource-constrained systems, calls to malloc() or free() should not be made in time-critical code, as the time it takes to execute these functions can vary greatly.
We will go into further detail on memory management in Chapter 7, A Comprehensive Look at Memory Management.
- 企業(yè)數(shù)字化創(chuàng)新引擎:企業(yè)級PaaS平臺HZERO
- 數(shù)據(jù)庫技術(shù)與應用教程(Access)
- Test-Driven Development with Mockito
- 計算機信息技術(shù)基礎實驗與習題
- 數(shù)據(jù)化網(wǎng)站運營深度剖析
- R數(shù)據(jù)科學實戰(zhàn):工具詳解與案例分析(鮮讀版)
- 數(shù)據(jù)結(jié)構(gòu)與算法(C語言版)
- 大數(shù)據(jù)時代下的智能轉(zhuǎn)型進程精選(套裝共10冊)
- Hadoop 3.x大數(shù)據(jù)開發(fā)實戰(zhàn)
- 智能數(shù)據(jù)時代:企業(yè)大數(shù)據(jù)戰(zhàn)略與實戰(zhàn)
- 大數(shù)據(jù)精準挖掘
- 數(shù)據(jù)庫原理與應用
- Oracle高性能SQL引擎剖析:SQL優(yōu)化與調(diào)優(yōu)機制詳解
- 數(shù)據(jù)庫應用系統(tǒng)技術(shù)
- 數(shù)據(jù)指標體系:構(gòu)建方法與應用實踐