StoryCode

'IT 용어, 인터넷 활용 등등'에 해당되는 글 25건

  1. ab (apache bench) 테스트
  2. Javascript.Hoisting
  3. whois.com 에서 whois.co.kr 로 이전하기
  4. Serverless Architecture
  5. Manage, Unmanaged, Native, JIT

ab (apache bench) 테스트

IT 용어, 인터넷 활용 등등
반응형

1) 설치

  1.1) Xampp 설치 ( https://www.apachefriends.org/download.html )

  1.2) CMD

  1.3) cd C:\xampp\apache\bin

  1.4) ab -n 1000 -c 20 -g gnuplot.dat -k -H "Accept-Encoding: gzip, default" http://example.com

 

2) -g 옵션 gnuplot 설명

 

참고 : https://stackoverflow.com/questions/5929104/apache-bench-gnuplot-output-what-are-the-column-definitions

-g 옵션 ( gnuplot ) 항목 설명

 

 

 

 

3) 초당 처리단위 계산을 위한 테스트 방법의 구상

  3.1) 최악의 경우 서비스 가능한 양을 측정하는 것이 좋다. 그러기 위해서는 가장 많이 서비스 되면서 가장 무거운 기능을 타겟으로 삼는 것이 좋다. 단순히 홈페이지 접속만으로 테스트할 경우 실제 상황에서는 대처가 안된다.

 

  3.2) "타겟한 기능" 이 단일 프로세스에서 몇 ms 가 걸리는 가를 추정 측정

ab -n 100 -c 1 으로 wait 평균. 많이 튈 경우 상하위 20% 씩 제거하고 나머지 60% 평균을 단일코어 1회 프로세스 타임으로 규정

 

  3.3) 3.2 와는 동일하나 zip 모드에서 얼마나 걸리는가 추정 측정. zip 으로 인한 부하가 커서 오히려 느려질 수 있으니 3.1 과 3.2 의 평균중 에서 낮은 방식으로 이후 테스트 진행

ab -n 100 -c 1 -H "Accept-Encoding: gzip, defalt" 으로 wait 평균.

 

  3.4) 이후 " 1초 / 단일코어 1회 프로세스 타임 " 으로 나눈 수 X Core 수 = CPU 능력치 를 C 에 대입한다.

ab -n 10000 -c CPU 능력치 -H "할지말지 선택" 으로 우선 테스트를 진행한다.

결과는 gnuplot.CPU능력치.result 로 저장.

 

  3.5) 하이퍼 쓰레드가 반영이 되는 경우도 있으므로,

ab -n 10000 -c CPU 능력치 X 2 -H "할지말지 선택" 으로 우선 테스트를 진행해본다.

결과는 gnuplot.CPU능력치X2.result 로 저장.

 

----------------------------------------------------------------------------------------

 

4) 초당 처리단위 계산을 위한 테스트 방법의 구상

- 테스트는 보수적으로 테스트해야 한다.

 

  4.1) 최악의 경우 서비스 가능한 양을 측정하는 것이 좋다. 그러기 위해서는 가장 많이 서비스 되면서 가장 무거운 기능을 타겟으로 삼는 것이 좋다. 단순히 홈페이지 접속만으로 테스트할 경우, index.html 같은 static file 만 테스트가 되므로 실제 상황에서는 대처가 안된다.

 

  4.2) "타겟한 기능" 이 단일 프로세스에서 CPU 부하가 몇 % 인지 측정하기 위해,

ab -n 100 -c 1 으로 부하를 준다음, 서버에서 sar 로 cpu 부하를 측정한다.

  참고 : 3.2 에서는, 가능하다면 1개의 Core 만으로 테스트 가능하면 좋다.

 

          이유는 하나의 트랜잭션이 0.03 초 같은 식으로 매우 짧을 경우인데,

          CPU 가 여러개일 경우 각각 다른 CPU 에서 트랜잭션이 수행되면 CPU 부하를 측정하기 힘들기 때문이다.

 

  4.3) 서버로 두개의 터미널을 띄운뒤,

한대에는 vmstat -t 1을 실행 ( 1 Core 일 경우 의미가 있음 )

한대에는 top 후 1 을 눌러서 Core 별  CPU 보이도록한다. ( MP 일 경우 의미가 있음 )

 

중요한 점은 ab 가 -c 1 이므로 1개의 Core 에만 몇 % 부하가 가는 지="단일프로세스Load측정치"를 확인한다.

 

만약, 서버 CPU 를 측정할 수 없다면, ab -g 옵션에서 wait 초="단일프로세스Load측정치"를 측정한다.

CPU 나 wait 가 많이 튈 경우 상하위 20% 씩 제거하고 나머지 60% 평균을 단일코어 1회 프로세스 타임으로 규정

 

  4.4) 3.2 와는 동일하나 zip 모드에서 얼마나 걸리는가 추정 측정. zip 으로 인한 부하가 커서 오히려 느려질 수 있으니 3.1 과 3.2 의 평균중 에서 낮은 방식으로 이후 테스트 진행

ab -n 100 -c 1 -H "Accept-Encoding: gzip, defalt" 으로도, CPU 혹은 wait "단일프로세스Load측정치" 를 측정해 본다.

 

  4.5) 이후 100% / CPU "단일프로세스Load측정치" 나 1초 / wait단일프로세스Load측정치 으로 나눈 수 X Core 수 = CPU 능력치 를 ab -c 에 대입한다.

ab -n 10000 -c CPU 능력치 -H "할지말지 선택" 으로 우선 테스트를 진행한다.

결과는 gnuplot.CPU능력치.result 로 저장.

  이 경우 top 이나 vmstat 를 확인하여 CPU 가 Full Load 인지 확인한다.

 

  4.6) 하이퍼 쓰레드가 반영이 되는 경우도 있으므로,

ab -n 10000 -c CPU 능력치 X 2 -H "할지말지 선택" 으로 우선 테스트를 진행해본다.

결과는 gnuplot.CPU능력치X2.result 로 저장.

  이 경우 top 이나 vmstat 를 확인하여 CPU 가 Full Load 인지 확인한다.

 

------------------------------------------------------------------------

 

  5) 상대방을 납득 시킬 수 있어야 한다.

만약 100tps 가 필요하다고 하면, 1초내에 100tps가 처리되야 한다는 뜻이다.

 

근데 1초 100tps 도 의미가 다양하다.

예를 들어 0초에 100개의 Request 가 동시에 발생할 수도 있고, 

0.0초에 10개의 Request, 0.1 초에 10개의 Request, 0.2 초에 10개의 Request...0.9초에 10개의 Request 가 발생할 수도 있다.

즉, Concurrent 최대 100 까지 했을 경우 처리가 잘되는 지 확인하는 것이다.

어쨌건 Concurrent 10부터 100 까지 적당한 간격으로 테스트하면서 처리시간과 Core 별 로드를 체크해보는 것이 중요하다.

 

이때 후자는 1초내에 처리가 될 수도 있지만, 전자는 안될 수도 있다.

 

 

 

 

 

 

 

추가 사용법 --------------------------------------------------------------------------------------------------------

- ab 에서 -v 4 옵션을 주면 모든 Request 의 Response 결과가 출력된다.

- gnuplot 차트실행 : script 를 먼저 만들고, gnuplot> load "script" 하던지, cmd > gnuplot "script" 한다.

 

추가 ------------------------------

windows 용 ab 는 2020년 5월 현재 2.4 가 최신이다.

2.3으로 하니 URL 이 길어서인지 안되는 게 좀 있어서 2.4 를 사용하는 것이 좋다.

 

https://www.apachelounge.com/download/

 

에서 "Apache 2.4.43 Win64" 을 받으면 ab 가 있으니 사용하면 된다.

 

 

반응형

'IT 용어, 인터넷 활용 등등' 카테고리의 다른 글

Software.Architect.AA, TA, DA, QA, BA  (0) 2020.08.21
CI, DI  (0) 2020.04.20
Javascript.Hoisting  (0) 2020.02.08
whois.com 에서 whois.co.kr 로 이전하기  (0) 2019.07.01
Serverless Architecture  (0) 2018.12.06

Javascript.Hoisting

IT 용어, 인터넷 활용 등등
반응형

"var 변수;" 와 "function 함수명" 으로 선언된 경우, 최상위에 미리 자동 선언된다.

고로, 함수내부에서 어디서든 불러 사용할 수 있다.

 

"let 변수" 와 "함수명 = function" 은 할당 혹은 정의 이전에 사용할 수 없다.

 

참조) https://gmlwjd9405.github.io/2019/04/22/javascript-hoisting.html

반응형

'IT 용어, 인터넷 활용 등등' 카테고리의 다른 글

CI, DI  (0) 2020.04.20
ab (apache bench) 테스트  (0) 2020.03.26
whois.com 에서 whois.co.kr 로 이전하기  (0) 2019.07.01
Serverless Architecture  (0) 2018.12.06
Manage, Unmanaged, Native, JIT  (0) 2018.12.02

whois.com 에서 whois.co.kr 로 이전하기

IT 용어, 인터넷 활용 등등
반응형

[ whois.co.kr ]

1) whois.co.kr 에 계정이 있어야 함.

 

2) 도메인 > 변경/이전 > 후이즈로 도메인 기관 이전

 

3) 등록기관 이전 신청에서 도메인 적고 "기관이전 신청" 등록 버튼 클릭 및 결제까지 진행해야 함.

 

4) 등록기관 이전 관리에 신청한 목록이 뜸.

주의사항) whois.com 에 접속해서, 이동할 도메인 클릭후, Theft Protection 을 Disable 해야 함.

 

5) Auth. Code 를 입력해야 함.

Auth.Code 확인하는 방법) 

whois.com 에 접속해서, Domain Secret 를 클릭하면 Code 가 나타나는데, 이 Code 를 복사해서 whois.co.kr 에 입력한다.

 

이후, 30 분쯤후에, whois.com 에 등록된 도메인 등록 메일로 아래와 같은 내용이 온다.

중요한 점은, 아래 붉은 글씨다. 일주일쯤 기다려야 이전이 된다. 아무런 액션을 취할 필요 없다.

------------------------------------------------------------------------------------------------------------------------------

Dear Customer,

Whois.com received notification on Monday, Jul 1, 2019 that you have requested a transfer to Whois Networks Co., Ltd. for mydomain.com. If you want to proceed with this transfer, you do not need to respond to this message. If you wish to cancel the transfer, please click on the below link before Saturday, Jul 6, 2019:

Cancel Transfer Link:

Click Here to cancel the transfer of mydomain.com 

If we do not hear from you by Saturday, Jul 6, 2019, the transfer will proceed.
------------------------------------------------------------------------------------------------------------------------------

 

주의사항) whois.co.kr 에서 Auth.Code 입력 버튼을 클릭해도, 처리중이라는 팝업만 뜰수 있는데, 이 경우, whois.co.kr 에 전화할 것.

 

반응형

'IT 용어, 인터넷 활용 등등' 카테고리의 다른 글

CI, DI  (0) 2020.04.20
ab (apache bench) 테스트  (0) 2020.03.26
Javascript.Hoisting  (0) 2020.02.08
Serverless Architecture  (0) 2018.12.06
Manage, Unmanaged, Native, JIT  (0) 2018.12.02

Serverless Architecture

IT 용어, 인터넷 활용 등등
반응형

[ 참고 자료 ] https://velopert.com/3543


- 서버가 없다는 뜻은 아님. 그렇다고 가상 머신도 아님.


- 굳이 언급하자면, 구글클라우드나 아마존클라우드에 코드를 실행한다.

  달리 서버가 필요한 것도 아님.


- BasS 와 FaaS 가 서버리스임.

  BasS = Backend as a Service = Firebase, Kinvey

  FaaS = Function as a Service = AWS Lambda, Azure Functions, Google Cloud Functions


- 추세

자체 전산실 =>

IaaS (Infrastructure as a Service) : 가상화=>

PaaS(Platform as a Service) : Application 배포 =>

Serverless(BaaS, Faas)

반응형

'IT 용어, 인터넷 활용 등등' 카테고리의 다른 글

CI, DI  (0) 2020.04.20
ab (apache bench) 테스트  (0) 2020.03.26
Javascript.Hoisting  (0) 2020.02.08
whois.com 에서 whois.co.kr 로 이전하기  (0) 2019.07.01
Manage, Unmanaged, Native, JIT  (0) 2018.12.02

Manage, Unmanaged, Native, JIT

IT 용어, 인터넷 활용 등등
반응형


[ 참조 ] http://diehard98.tistory.com/entry/Managed-%EC%BD%94%EB%93%9C-Unmanaged-%EC%BD%94%EB%93%9C-%EA%B7%B8%EB%A6%AC%EA%B3%A0-Native-%EC%BD%94%EB%93%9C%EC%97%90-%EB%8C%80%ED%95%9C-%EC%9D%B4%EC%95%BC%EA%B8%B0


Managed 코드, Unmanaged 코드 그리고 Native 코드에 대한 이야기

Managed, Unmanaged, Native: What Kind of Code Is This?

http://www.developer.com/net/cplus/article.php/2197621/Managed-Unmanaged-Native-What-Kind-of-Code-Is-This.htm

With the release of Visual Studio .NET 2003 (formerly known as Everett) on April 24th, many developers are now willing to consider using the new technology known as managed code. But especially for C++ developers, it can be a bit confusing. That's because C++, as I pointed out in my first column here, is special.

1. What Is Managed Code? – Managed code?

Managed Code is what Visual Basic .NET and C# compilers create. It compiles to Intermediate Language (IL), not to machine code that could run directly on your computer. The IL is kept in a file called an assembly, along with metadata that describes the classes, methods, and attributes (such as security requirements) of the code you've created. This assembly is the one-stop-shopping unit of deployment in the .NET world. You copy it to another server to deploy the assembly there—and often that copying is the only step required in the deployment.

Manage code  무엇인가? Managed code Visual Basic .NET C# 컴파일러가 만들어내는 것을말한다 컴파일러들은 우선 IL(Intermediate Language – 중간 언어라고 불리는 코드를 만들어 낸다 IL 컴파일을 수행한 당신의 컴퓨터에서 바로 실행되기 위한 machine code (기계 언어) 아니라는  알아야 한다이렇게 생성된 IL 어셈블리라고 불리는 파일에 저장되고 이때 메타 데이터도함께 저장하는데  메타 데이터들은 내가 컴파일한 코드의 클래스함수 그리고 변수  속성 (보안 관련 속성도 포함)등을 가진다이제  어셈블리 파일은 .NET 세계에서 배달 완료된 모든 내용이 포장된일종의 상품이다당신은 이것을 다른 서버에 복사하여 deploy (배포)하기만 하면 된다.

Managed code runs in the Common Language Runtime. The runtime offers a wide variety of services to your running code. In the usual course of events, it first loads and verifies the assembly to make sure the IL is okay. Then, just in time, as methods are called, the runtime arranges for them to be compiled to machine code suitable for the machine the assembly is running on, and caches this machine code to be used the next time the method is called. (This is called Just In Time, or JIT compiling, or often just Jitting.)

Managed code 이른바 Common Language Runtime (줄여서 CLR) 환경에서 동작한다 CLR내가 작성한 코드가 실행될  다양한 형태의 서비스를 지원한다여기서 주의 깊게 봐야 하는 단어는실행될 이다일반적인 경우, CLR 우선 어셈블리 파일을 읽은 다음 IL 괜찮은지부터 확인한다그리고 함수가 호출되는 순간 CLR 현재 프로그램이 돌아가는 컴퓨터의 환경에 적합한 기계 언어를만들어 낸다그리고  함수가 다음 번에 호출되면 바로 사용될  있게 하기 위해서 만들어진 기계언어 코드를 cache (캐시) 저장해 둔다이것이 바로 Just In Time 혹은 줄여서 JIT 컴파일링 이라 불리는 기법이다여기서 중요한 것은 현재 프로그램이 돌아가는 컴퓨터 환경에 적합한 기계 언어 생성이다이것이 바로 CLR 강점이다.

As the assembly runs, the runtime continues to provide services such as security, memory management, threading, and the like. The application is managed by the runtime.

어셈블리가 실행되는 동안 CLR 보안메모리 관리스레딩에 관련된 서비스 일체를 제공하고 이런 프로그램을 우리는 ‘Runtime 의해 Managed (관리되는프로그램이다 라고 한다.

Visual Basic .NET and C# can produce only managed code. If you're working with those applications, you are making managed code. Visual C++ .NET can produce managed code if you like: When you create a project, select one of the application types whose name starts with .Managed., such as .Managed C++ application..

Visual Basic .NET C# 오직 managed 코드만 생성가능 하다만약 당신이  프로그램들을 사용한다면 당신은 managed code 생성해 내고 있는 것이다반면 Visual C++ .NET 내가 원하면managed code 생성할 수도 있고 아니면 unmanaged code 생성할 수도 있다이것은 Visual Studio 프로젝트 속성에서 변경 가능하다.

2. What Is Unmanaged Code? – Unmanaged code ?

Unmanaged code is what you use to make before Visual Studio .NET 2002 was released. Visual Basic 6, Visual C++ 6, heck, even that 15-year old C compiler you may still have kicking around on your hard drive all produced unmanaged code. It compiled directly to machine code that ran on the machine where you compiled it—and on other machines as long as they had the same chip, or nearly the same. It didn't get services such as security or memory management from an invisible runtime; it got them from the operating system. And importantly, it got them from the operating system explicitly, by asking for them, usually by calling an API provided in the Windows SDK. More recent unmanaged applications got operating system services through COM calls.

Unmanaged code Visual Studio .NET 2002 나오기 전에 만든 코드를 말한다, Visual Basic 6, Visual C++ 6 그리고 15 이상된 C 컴파일러 또한 Unmanaged code 생성해 낸다이것들은 내가컴파일을 수행하는 바로  컴퓨터 적합한 기계 코드를 생성 낸다. (Managed code 처럼 IL 생성과정이 없다.) 고로 이렇게 생성해낸 기계 언어는 같은   하드웨어 구성을 가지지 다른 컴퓨터에서는 돌아갈지 모르나 다른 구성을 가지는 컴퓨터에서는 당연히 실행 불가다또한 이렇게 생성된unmanaged code 보안  메모리 관리 서비스를 실행시에 Runtime으로부터 받을 수가 없다대신OS(Windows)로부터 받는다여기서 중요한 점은 OS로부터 서비스를 받기는 하지만 이것은 Windows SDK 제공하는 특정 함수 (API) 호출함으로써 가능하다근래의 Unmanaged code 운영체제의서비스를 COM call 의해 제공받는다라고 했다 글이 2004 글이므로 COM 근래의 언어라고표현한 것이 이해가 간다아무튼요약하자면 managed code 경우 runtime 알아서 메모리 관리를해주는데 반해 (Garbage collection) unmanaged code 경우사용자에게  책임이 있다는 점이다다만 COM 같이 발전된 형태의 라이브러리들은 스스로 객체의 파괴를 관리하는 능동성을 가지고는 있다.

Unlike the other Microsoft languages in Visual Studio, Visual C++ can create unmanaged applications. When you create a project and select an application type whose name starts with MFC, ATL, or Win32, you're creating an unmanaged application.

다른 Microsoft  언어들과는 다르게 Visual C++ unmanaged 프로그램을 만들  있다. MFC, ATL혹은 Win32  생성되는 프로젝트들은 모두 unmanaged application이다.

This can lead to some confusion: When you create a .Managed C++ application., the build product is an assembly of IL with an .exe extension. When you create an MFC application, the build product is a Windows executable file of native code, also with an .exe extension. The internal layout of the two files is utterly different. You can use the Intermediate Language Disassembler, ildasm, to look inside an assembly and see the metadata and IL. Try pointing ildasm at an unmanaged exe and you'll be told it has no valid CLR (Common Language Runtime) header and can't be disassembled—Same extension, completely different files.

당연히 Visual C++ Managed application 만들 수도 있다이때 .exe 확장자를 가지는 IL 어셈블리가 만들어진다만약 당신이 MFC 프로그램(unmanaged code) 만든다면 이것은 똑같은 확장자인.exe 가지는 native code 생성해  것이다여기서 혼란이  수도 있다같은 .exe 확장자를 가지니까 뭐가 뭔지 모를  있다 둘을 구분하기 위해서는 Intermediate Language Disassembler, 줄여서 ildasm이라 불리는 놈으로 어셈블리와 메타 데이터를 들여다 보면 된다. Unmanaged codeildasm으로 보려고 하면 유효한 CLR 헤더가 없다고 에러 메시지를 출력할 것이란다  개의.exe 파일은 완전히 다른 형태의 파일이다.

3. What about Native Code? – Native code?

The phrase native code is used in two contexts. Many people use it as a synonym for unmanaged code: code built with an older tool, or deliberately chosen in Visual C++, that does not run in the runtime, but instead runs natively on the machine. This might be a complete application, or it might be a COM component or DLL that is being called from managed code using COM Interop or PInvoke, two powerful tools that make sure you can use your old code when you move to the new world. I prefer to say .unmanaged code. for this meaning, because it emphasizes that the code does not get the services of the runtime. For example, Code Access Security in managed code prevents code loaded from another server from performing certain destructive actions. If your application calls out to unmanaged code loaded from another server, you won't get that protection.

Native code  가지의 의미를 가지고 있다우선 Native code 함은 Unmanaged code 동의어로사용된다옛날 버전의 컴파일러로 컴파일 되었거나 Visual C++에서 일부러 선택한 컴파일러에 의해 해당 컴퓨터에 적합한 기계언어의 생성을 말하며 이는 런타임시 (실행되는 순간) CLR 의해 아무런 서비스를 받을  없다는 것을 의미한다이런 Native code(Unmanaged code) 하나의 완전한 프로그램 수도 있고, COM 컴포넌트  수도 있고혹은 Managed code내부에서 호출된 DLL 수도 있다하지만 이런 경우 ‘Unmanaged code’라고 하는 것이  합당한데 왜냐면 Unmanaged code라는 것이 실행시에 Runtime으로부터 서비스를 받을수 없다는 것을 분명히 강조하기 때문이란다예를 들어 설명한것이 서로 다른 컴퓨터에서 실행되는 프로그램이 Managed code 경우 보안 관련 서비스를 실행시(Runtime) 받을수 있으나 Unmanaged code 경우 그럴  없다는 .

The other use of the phrase native code is to describe the output of the JIT compiler, the machine code that actually runs in the runtime. It's managed, but it's not IL, it's machine code. As a result, don't just assume that native = unmanaged.

 다른 의미의 Native code JIT 컴파일로부터 생성된 코드를 말한단다. JIT Managed code에만 사용되므로 이것은 분명 Managed code이지만 IL 코드가 아니고 해당 컴퓨터에 적합한 기계언어이다고로 Native라는 단어를 무조건적으로 Unmanaged라고 생각하지 말라.

Does Managed Code Mean Managed Data? – Managed code Managed Data 의미하나?

Again with Visual Basic and C#, life is simple because you get no choice. When you declare a class in those languages, instances of it are created on the managed heap, and the garbage collector takes care of lifetime issues. But in Visual C++, you get a choice. Even when you're creating a managed application, you decide class by class whether it's a managed type or an unmanaged type. This is an unmanaged type:

Visual Basic이나 C# 사용한다면 모든 것이 Managed code이므로 오히려 간단하다고로 내가 만약 언어들을 사용해서 프로그램을 작성한다면클래스를 하나 선언하고 객체화를 했을   객체는Managed Heap 생성되고 Garbage Collector 알아서 메모리를 수거해 간다하지만 내가 만약Visual C++ 사용한다면 나는 각각의 클래스를 선언할  마다 선택을  수가 있게 된다이른바 클래스가 Managed type인가 아니면 Unmanaged type인가를 다음과 같이 결정한다우선 Unmanaged type 경우 다음과 같이 선언한다.

class Foo

{

private:

   int x;

public:

    Foo(): x(0){}

    Foo(int xx): x(xx) {}

};

 

This is a managed type:

그리고 Managed type 경우 다음과 같다.

__gc class Bar

{

private:

   int x;

public:

    Bar(): x(0){}

    Bar(int xx): x(xx) {}

};

The only difference is the __gc keyword on the definition of Bar. But it makes a huge difference.

차이점이라고는 클래스 선언 앞부분에 __gc 붙냐 안붙냐 차이 밖에 없다하지만  차이는 엄청나다.

Managed types are garbage collected. They must be created with new, never on the stack. So this line is fine:

Foo f;

Managed type garbage collector 의해 자동으로 메모리가 수거 된다고로  놈들은 반드시 new 이용해서 생성해야 하며 절대로 stack 생성될  없다고로 위에 Unmanaged type으로 생성한Foo 클래스의 경우  명령처럼 스택에 선언할  있지만,

But this line is not allowed:

Bar b;

Managed type으로 선언한 Bar 클래스의 경우 Foo 클래스와 같은 방식으로 스택에 선언  수가 없다.

If I do create an instance of Foo on the heap, I must remember to clean it up:

Foo* pf = new Foo(2);

// . . .

delete pf;

The C++ compiler actually uses two heaps, a managed an unmanaged one, and uses operator overloading on new to decide where to allocate memory when you create an instance with new.

만약 내가 Foo 클래스를 힙에 선언한다면 (다른 말로 포인터 생성하여 new 객체화  경우), 반드시메모리 삭제를 delete 통해서 파괴해야 한다. C++ 컴파일러는 실제로 두개의 힙을 사용하는데 각각은managed unmanaged 위한 것이다. new 라는 키워드는 오버로딩을 통해서 managedunmanaged  중에 하나를 선택하여 메모리 할당한다.

If I create an instance of Bar on the heap, I can ignore it. The garbage collector will clean it up some after it becomes clear that no one is using it (no more pointers to it are in scope).

There are restrictions on managed types: They can't use multiple inheritance or inherit from unmanaged types, they can't allow private access with the friend keyword, and they can't implement a copy constructor, to name a few. So, you might not want your classes to be managed classes. But that doesn't mean you don't want your code to be managed code. In Visual C++, you get the choice.

반대로 만약 내가 Bar 클래스를 힙에 생성하면 나는 간단히 신경 끄면 그만이다? Garbage collector 알아서 메모리를 수거할 테니

, managed type에는 몇가지 제약이 있으니 바로 다중 상속이 안되며 unmanaged type으로 부터의상속이 안된다는 제약이다또한 private 속성에 대한 접근이 friend 키워드를 통해서도 안되고복사 생성자를 구현  수가 없단다요런 저런 제약을 보아하니 아마도 당신은 managed class 만들고 싶지않을 수도 있다하지만 그것이 당신의 프로그램 전체가 managed code 아니길 바란다는 것은 아닐것이다 (managed unmanaged 섞어 써도 된다는 ). 암튼, C++에서는 프로그래머가 선택할 있다.

결론만 말하자면,

1. Managed code는 CLR에 의해 제공되는 실행시의 각종 서비스 (보안 및 메모리 관련)를 받을 수 있는 것을 말한다.
2. Managed code는 CLR에 의해 해당 컴퓨터에 적합한 기계 언어를 능동적으로 생성하여 범용성을 높였다.
3. Unmanaged code는 실행시의 CLR이 제공하는 서비스를 제공받을 수 없다.
4. Unmanaged code는 컴파일할때 컴퓨터의 환경에 적합한 기계어만 생성하므로 범용성이 매우 낮다.
5. Native code는 '기계 언어'라고 보는 것이 적합하며 Native code를 Unmanaged code라고 생각하면 안된다.
6. Visual C++는 Managed Type과 Unmanaged Type의 클래스를 생성할 수 있다.
7. Managed Type 클래스는 힙에 생성되면 자동으로 메모리 수거가 이루어 지는 반면 Unmanaged Type 클래스는 사용자가 수거해야 한다. 
8. __gc를 클래스 선언시 사용하면 Managed Type 클래스를 선언 할 수 있다.

About the Author

Kate Gregory is a founding partner of Gregory Consulting Limited (www.gregcons.com). In January 2002, she was appointed MSDN Regional Director for Toronto, Canada. Her experience with C++ stretches back to before Visual C++ existed. She is a well-known speaker and lecturer at colleges and Microsoft events on subjects such as .NET, Visual Studio, XML, UML, C++, Java, and the Internet. Kate and her colleagues at Gregory Consulting specialize in combining software develoment with Web site development to create active sites. They build quality custom and off-the-shelf software components for Web pages and other applications. Kate is the author of numerous books for Que, including Special Edition Using Visual C++ .NET.

 


반응형

'IT 용어, 인터넷 활용 등등' 카테고리의 다른 글

CI, DI  (0) 2020.04.20
ab (apache bench) 테스트  (0) 2020.03.26
Javascript.Hoisting  (0) 2020.02.08
whois.com 에서 whois.co.kr 로 이전하기  (0) 2019.07.01
Serverless Architecture  (0) 2018.12.06