竞技场一词与记忆有关的含义是什么? [英] What is the meaning of the term arena in relation to memory?

查看:98
本文介绍了竞技场一词与记忆有关的含义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在读一本关于内存的书,这是一个编程概念.在随后的几章中,作者大量使用了 arena (竞技场)一词,但从未对其进行定义.我搜索了该词的含义以及它与记忆的关系,但没有发现任何结果.以下是作者使用该术语的几种情况:

I'm reading a book on memory as a programming concept. In one of the later chapters, the author makes heavy use of the word arena, but never defines it. I've searched for the meaning of the word and how it relates to memory, and found nothing. Here are a few contexts in which the author uses the term:

序列化的下一个示例包含了一种称为 来自特定竞技场的内存分配."

"The next example of serialization incorporates a strategy called memory allocation from a specific arena."

"...这在处理内存泄漏或分配内存时很有用 来自特定的竞技场."

"...this is useful when dealing with memory leaks or when allocating from a specific arena."

"......如果我们要取消分配内存,那么我们将取消分配内存 整个竞技场."

"...if we want to deallocate the memory then we will deallocate the whole arena."

作者在一章中使用了100次以上的术语.词汇表中的唯一定义是:

The author uses the term over 100 times in one chapter. The only definition in the glossary is:

从竞技场分配-先分配竞技场然后分配的技术 通过程序管理竞技场内的分配/取消分配 本身(而不是进程内存管理器);用于 复杂数据结构和对象的压缩和序列化, 或用于安全关键和/或容错的内存管理 系统.

allocation from arena - Technique of allocating an arena first and then managing the allocation/deallocation within the arena by the program itself (rather then by the process memory manager); used for compaction and serialization of complex data structures and objects, or for managing memory in safety-critical and /or fault-tolerant systems.

在这些情况下,谁能为我定义竞技场?

Can anyone define arena for me given these contexts?

推荐答案

竞技场只是一块巨大的连续内存,您可以分配一次,然后通过分发一部分内存来手动管理内存.例如:

An arena is just a large, contiguous piece of memory that you allocate once and then use to manage memory manually by handing out parts of that memory. For example:

char * arena = malloc(HUGE_NUMBER);

unsigned int current = 0;

void * my_malloc(size_t n) { current += n; return arena + current - n; }

重点是您可以完全控制内存分配的工作方式.唯一无法控制的是对初始分配的单个库调用.

The point is that you get full control over how the memory allocation works. The only thing outside your control is the single library call for the initial allocation.

一个流行的用例是,每个竞技场仅用于分配一个固定大小的单个内存块.在这种情况下,您可以编写非常有效的回收算法.另一个用例是每个任务"都有一个竞技场,当您完成任务后,您可以一次性释放整个竞技场,而不必担心跟踪单个的解除分配.

One popular use case is where each arena is only used to allocate memory blocks of one single, fixed size. In that case, you can write very efficient reclamation algorithms. Another use case is to have one arena per "task", and when you're done with the task, you can free the entire arena in one go and don't need to worry about tracking individual deallocations.

这些技术中的每一种都是非常专业的,并且通常仅在您确切知道您在做什么以及为什么正常的库分配不够好时才派上用场.请注意,一个好的内存分配器本身已经可以做很多事情了,在开始自己处理内存之前,您需要大量的证据来证明这还不够好.

Each of those techniques is very specialized and generally only comes in handy if you know exactly what you're doing and why the normal library allocation is not good enough. Note that a good memory allocator will already do lots of magic itself, and you need a decent amount of evidence that that's not good enough before you start handling memory yourself.

这篇关于竞技场一词与记忆有关的含义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆