Share via


_CrtSetBreakAlloc

지정한 개체 할당 순서 대로 숫자 (디버그 버전에만 해당)에 중단점을 설정합니다.

long _CrtSetBreakAlloc( 
   long lBreakAlloc 
);

매개 변수

  • lBreakAlloc
    설정할 중단점의 할당 순서 번호

반환 값

중단점을 설정 해야 했던 이전 개체 할당 주문 번호를 반환 합니다.

설명

_CrtSetBreakAlloc응용 프로그램을 메모리 누수 탐지 메모리 할당 중 특정 시점에서 중단 하 고 요청을 원래 위치에 다시 추적을 수행할 수 있습니다.순차적 개체 할당 순서 번호 힙에서 할당 된 메모리 블록으로 할당 함수를 사용 합니다.때 _DEBUG 정의 되지 않은, 호출 하려면 _CrtSetBreakAlloc 전처리 하는 동안 제거 됩니다.

개체 할당 순서 번호가 저장 됩니다는 lRequest 필드는 _CrtMemBlockHeader crtdbg.h에 정의 된 구조체입니다.디버그 덤프 함수 중 하나가 메모리 블록에 대 한 정보를 보고 하는 경우이 숫자 {36}와 같이 중괄호에 포함 합니다.

방법에 대 한 자세한 내용은 _CrtSetBreakAlloc 기타 메모리 관리 기능을 사용할 수 있습니다 자세한 내용은 힙 할당 요청 추적.

요구 사항

루틴

필수 헤더

_CrtSetBreakAlloc

<crtdbg.h>

더 많은 호환성 정보를 참조 하십시오. 호환성 소개에서 합니다.

라이브러리

디버그 버전의 C 런타임 라이브러리 만 합니다.

예제

// crt_setbrkal.c
// compile with: -D_DEBUG /MTd -Od -Zi -W3 /c /link -verbose:lib -debug

/*
 * In this program, a call is made to the _CrtSetBreakAlloc routine
 * to verify that the debugger halts program execution when it reaches
 * a specified allocation number.
 */

#include <malloc.h>
#include <crtdbg.h>

int main( )
{
        long allocReqNum;
        char *my_pointer;

        /* 
         * Allocate "my_pointer" for the first
         * time and ensure that it gets allocated correctly
         */
        my_pointer = malloc(10);
        _CrtIsMemoryBlock(my_pointer, 10, &allocReqNum, NULL, NULL);

        /* 
         * Set a breakpoint on the allocation request
         * number for "my_pointer"
         */
        _CrtSetBreakAlloc(allocReqNum+2);
        _crtBreakAlloc = allocReqNum+2;

        /* 
         * Alternate freeing and reallocating "my_pointer"
         * to verify that the debugger halts program execution
         * when it reaches the allocation request
         */
        free(my_pointer);
        my_pointer = malloc(10);
        free(my_pointer);
        my_pointer = malloc(10);
        free(my_pointer);
}

해당 .NET Framework 항목

해당 사항 없음. 표준 C 함수를 호출할 수 있습니다 PInvoke. 자세한 내용은 플랫폼 호출 예제.

참고 항목

참조

루틴을 디버깅 합니다.