[C#/COMMON/.NET6] GCHandle 클래스 : Alloc 정적 메소드를 사용해 객체의 가비지 수집을 방지하는 핸들 구하기
C#/Common 2022. 10. 19. 16:31728x90
반응형
728x170
■ GCHandle 클래스의 Alloc 정적 메소드를 사용해 객체의 가비지 수집을 방지하는 핸들을 구하는 방법을 보여준다.
▶ 예제 코드 (C#)
using System.Runtime.InteropServices;
using System.Text;
byte[] sourceByteArray = Encoding.UTF8.GetBytes("안녕하세요");
GCHandle targetGCHandle = GCHandle.Alloc(sourceByteArray, GCHandleType.Pinned);
728x90
반응형
그리드형(광고전용)
댓글을 달아 주세요