Skip to Content
이펙티브 러스트
book

이펙티브 러스트

by 데이비드 드라이스데일, 남기혁
October 2024
Beginner to intermediate
344 pages
7h 44m
Korean
Hanbit Media, Inc.
Content preview from 이펙티브 러스트
144
이펙티브 러스트
아이템
14
: 수명을 잘 파악하라
이번에는 러스트의 수명
lifetime
을 알아본다. 수명이라는 개념은
C
C
++를 비롯한 기존 컴파일
언어에도 있었지만 러스트에서는 이 개념을 이론보다는 실용적인 관점으로 더 정확하게 정리
했다. 수명은 아이템
15
에서 설명하는 대여 검사기의 필수 입력으로, 러스트에서 메모리 안전
성을 보장하는 데 핵심적인 요소다.
스택
수명은 기본적으로 스택
stack
과 연관된다. 여기서 스택을 간단히 소개하며 여러분의 기억을 되
살리고 넘어가려 한다.
프로그램이 실행되는 동안 사용하는 메모리는 세그먼트
segment
단위로 나뉜다. 그중 일부는 프
로그램 코드나 글로벌 데이터를 저장하는 세그먼트처럼 크기가 일정하지만, 힙
heap
과 스택은
프로그램 실행 중에 상태에 따라 크기가 달라진다. 이를 위해 [그림
3
-
1
]처럼 프로그램 가상
메모리 공간의 양쪽 끝에 힙과 스택이 배치된다. 그래야 하나는 아래쪽으로, 다른 하나는 위쪽
으로 확장할 수 있다. 적어도 메모리가 부족해 충돌이 발생하기 전까지는 말이다.
스택
확장
확장
글로벌 데이터
코드
그림
3-1
스택은 아래로, 힙은 위로 증가하도록 배치된 프로그램 메모리 레이아웃
145
3
주요 개념
이처럼 크기가 동적으로 변하는 두 가지 세그먼트 중에서도 스택은 현재 실행 중인 함수의 상
태 정보를 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

이펙티브 타입스크립트

이펙티브 타입스크립트

Dan Vanderkam
파이썬으로 살펴보는 아키텍처 패턴

파이썬으로 살펴보는 아키텍처 패턴

오현석, 해리 퍼시벌, 밥 그레고리

Publisher Resources

ISBN: 9791169212946