Login Page - Create Account

Support Board


Date/Time: Sun, 19 May 2024 01:39:21 +0000



Post From: Allocating Dynamic Memory for Classes

[2016-07-11 14:09:51]
skelcap - Posts: 139
Looking here:

https://www.sierrachart.com/index.php?page=doc/doc_ACSILProgrammingConcepts.html#DynamicMemoryAllocations

I understand you can't use new/delete with Visual C++ in Debug mode because the CRT debug heap crashes on delete when it can't find the allocated block (because the heap list gets cleared when the DLL unloads). So for arrays and unstructured memory blocks you offer the AllocateMemory/FreeMemory functions.

However for classes with constructors/destructors you still suggest new/delete, which doesn't work in debug mode for the above reason. What do you suggest? Obviously it does work in release mode but then you can't debug. Is there a way to disable the CRT debug heap in Debug mode? I guess I could just use AllocateMemory/FreeMemory and write my own construction/destruction routines to be called explicitly without calling new/delete, but wondering if there's a better way ...