malloc的回报内存或虚拟空间ADRESS [英] malloc returns memory or virtual adress space

查看:125
本文介绍了malloc的回报内存或虚拟空间ADRESS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这一次困扰我。

是否的malloc分配的内存块堆上还是应该叫虚拟空间ADRESS?

Does malloc allocate a block of memory on the heap or should it be called Virtual Adress Space?

我是不是挑剔叫它虚拟空间ADRESS或本只是DOS的遗产?如何Linux呢?

Am I being picky calling it Virtual Adress Space or this just the legacy of DOS? How about Linux?

编辑:

以极大的细节很多答案,他们没有回答我的问题,虽然。

many answers with great details, none of them answer my question, though.

推荐答案

要回答这个问题,我们需要知道什么样的操作系统和架构,我们正在处理。由于PMG提标准和文章提到存储或空间。这些是最​​笼统和唯一有效的,除非我们做了一堆假设。

To answer this question, we need to know what kind of Operating System and architecture we are dealing with. As pmg mention the Standard and articles refers to "storage" or "space". These are the most general terms and the only valid ones, unless we make a bunch of assumptions.

例如:

malloc分配虚拟块
  堆地址空间

malloc allocates a block of Virtual Address Space on the heap

这是不是很多嵌入式系统是正确的。他们中的许多不使用虚拟内存,因为没有必要(无多任务等)或出于性能原因。更重要的是,它有可能一些外来设备不具有堆的想法 - 怀疑的malloc将被使用,但相当也就是说的原因之一的标准是指存储 - 它是实现特定的。

This is not correct for many embedded systems. Many of them do not use Virtual Memory, because there is no need (no multitasking etc.) or for performance reasons. What is more, it is possible that some exotic device does not have the idea of heap – doubt that malloc would be used, but fairly that is one of the reasons why the Standard refers to "storage" - it is implementation-specific.

在另一方面,该实施例是在我们的PC Window和Linux正确。让我们来分析它来回答这个问题。

On the other hand, the example is correct for Window and Linux in our PCs. Let's analyze it to answer the question.

首先,我们需要定义什么是虚拟地址空间。

First off, we need to define what is Virtual Address Space.

虚拟地址空间(VAS)是一个内存映射机制与管理多个进程有所帮助。

Virtual Address Space (VAS) is a memory mapping mechanism that helps with managing multiple processes.


  • 分离过程 - 他们每个人都有
    他自己的地址空间

  • 允许分配内存32位
    架构限制为。

  • 提供了一个内存简洁模式

返回的问题,做的malloc在堆上分配的内存块,还是应该被称为虚拟空间ADRESS?

Back to question, "Does malloc allocate a block of memory on the heap or should it be called Virtual Adress Space ?"

两个语句都是正确。我宁愿说VAP,而不是记忆 - 这是更加明确。有一种普遍的神话的malloc = RAM内存。早在老的一天,DOS内存分配很简单。每当我们要求对于内存,总是RAM,但在现代的操作系统可能会有所不同。

Both statements are correct. I would rather say VAP instead of memory – it is more explicit. There is a common myth that malloc = RAM memory. Back in old day, DOS memory allocation was very simple. Whenever we ask for memory it was always RAM, but in modern Oses it may vary.

这篇关于malloc的回报内存或虚拟空间ADRESS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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