Foo* set = new Foo[100]; // ... delete [] set;
You don’t pass the array’s boundaries to delete[]. But where is that information stored? Is it standardised?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When you allocate memory on the heap, your allocator will keep track of how much memory you have allocated. This is usually stored in a ‘head’ segment just before the memory that you get allocated. That way when it’s time to free the memory, the de-allocator knows exactly how much memory to free.