不要线程具有鲜明的堆? [英] Do threads have a distinct heap?

查看:85
本文介绍了不要线程具有鲜明的堆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,每个线程得到一个不同的栈时,由操作系统创建的线程。我不知道是否每个线程都有不同的自身堆也?

As far as I know each thread gets a distinct stack when the thread is created by the operating system. I wonder if each thread has a heap distinct to itself also?

推荐答案

没有。所有线程共享一个共同的堆。

No. All threads share a common heap.

每个线程有一个专用栈,它可以快速添加和删除项目。这使得基于堆栈存储器快,但如果你使用太多堆栈存储器,如发生无限递归,你会得到一个堆栈溢出。

Each thread has a private stack, which it can quickly add and remove items from. This makes stack based memory fast, but if you use too much stack memory, as occurs in infinite recursion, you will get a stack overflow.

由于所有线程共享同一个堆,获得了分配器/释放必须同步。有避免分配器争的各种方法和库。

Since all threads share the same heap, access to the allocator/deallocator must be synchronized. There are various methods and libraries for avoiding allocator contention.

有些语言允许您创建的内存私人游泳池,或个人堆,它可以分配到单个线程。

Some languages allow you to create private pools of memory, or individual heaps, which you can assign to a single thread.

这篇关于不要线程具有鲜明的堆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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