Freeing memory error?

前端 未结 2 373
栀梦
栀梦 2020-12-21 12:49

I need to free the bitpointer, because this function is executed multiple times and memory usage is growing for a reason I don\'t understand and it crashes afte

2条回答
  •  一整个雨季
    2020-12-21 13:17

    If you read the documentation you'll see that you shouldn't be allocating memory for bitPointer, CreateDIBSection does that for you. You need to use DeleteObject to free hBitmap2.

    The crash occurs because the value of bitPointer youi are freeing is not the one that you allocated. (And the memory you allocated is leaked.)

提交回复
热议问题