Skip to content

Magic number

In computer programming, the term magic number has multiple meanings.

About

아래와 같은 의미가 존재한다.

  • 파일 포맷 또는 프로토콜을 식별하는 데 사용되는 정수 숫자 또는 문자 값.
  • 특정 의미가 부여된 유일한 값. (e.g., Globally Unique Identifiers)
  • 설명 없이 무작정 등장하는 상수 (부정적 의미다)
  • 상수로 대체될 수 있는 여러 번 반복되는 값.

Magic GUIDs

It is possible to create or alter globally unique identifiers (GUIDs) so that they are memorable, but this is highly discouraged as it compromises their strength as near-unique identifiers.

Magic debug values

0xCCCCCCCC
Microsoft's C++ debugging runtime library and many DOS environments.
초기화 되지 않는 스택 메모리를 마킹하는 용도로 사용된다.
0xFDFDFDFD
Used by Microsoft's C/C++ debug malloc() function.
to mark "no man's land" 메모리 가이드 밴드(guard bytes)1 before and after allocated heap memory.

Favorite site

References


  1. 힙에 할당된 메모리의 앞과 뒤에 기록되는 값이다. 디버거는 항상 이 값을 감시하며, 이 가이드 밴드 부분의 메모리가 파손되면 힙 크래시가 발생한 것으로 보고 런타임 에러를 발생한다.