0

C++ Memory Management is broken

I'm messing around with memory management in c++, but I got weird output. It doesn't say its an error or warning, it says free(): double free detected in tcache2. What does it mean? https://code.sololearn.com/coS0bmKqyRJ7/?ref=app

27th Jun 2020, 9:04 PM
Clueless Coder
Clueless Coder - avatar
2 Answers
+ 3
You are doing free and delete on ptr. free(ptr); delete ptr; Please remove one of them.
27th Jun 2020, 9:07 PM
$Ā¢šŽā‚¹š”­!šØš“
$Ā¢šŽā‚¹š”­!šØš“ - avatar
+ 2
Remove delete ptr; usually delete is used with new. And free with malloc and calloc.
27th Jun 2020, 9:09 PM
$Ā¢šŽā‚¹š”­!šØš“
$Ā¢šŽā‚¹š”­!šØš“ - avatar