Sets the memory allocation method used in the dicom library.
Type of memory allocation. Possible values are:
|MEMORY_FAR||Memory allocated using malloc(). This is the default. This method is fast, but objects allocated with this method can not be modified in other DLLs.|
|MEMORY_GLOBAL||Memory allocated using the Windows C API GlobalAlloc(). This method is slower than the default. Objects allocated with this method can be modified in other DLLs.|
|MEMORY_FAIL||Failed to change the method of memory allocation.|
|MEMORY_FAR||Previous method of memory allocation was malloc()|
|MEMORY_GLOBAL||Previous method of memory allocation was GlobalAlloc()|
In most cases, you do not need to call this function. However if your application consists of multiple processes as in the case of multiple DLLs, and you need to pass pointers to objects allocated inside the current DLL to other processes that will eventually free those objects, then you will need to call this function with the MEMORY_GLOBAL flag (preferably at the beginning of your application) to ensure proper behavior. For example if you are creating a DICOM dataset inside your application and you want to pass a pointer to that dataset to a method inside a COM object which will modify that dataset then you need to call this function with the MEMORY_GLOBAL flag.
Note: This function should be used carefully. Objects created with MEMORY_FAR should only be modified with MEMORY_FAR . Likewise, objects created with MEMORY_GLOBAL should only be modified with MEMORY_GLOBAL. Do not create Dicom objects with one type of memory allocation, change the memory allocation method, and then modify the original object.
Win32, x64, Linux.
This example sets the memory allocation method to GlobalAlloc()
and displays the previous memory allocation method.
L_TCHAR *pszPrev = TEXT("");
uRet = L_DicomSetMemoryAllocation(MEMORY_GLOBAL);
pszPrev = TEXT("Previous memory allocation method: malloc");
pszPrev = TEXT("Previous memory allocation method: GlobalAlloc");
pszPrev = TEXT("L_DicomSetMemoryAllocation failed--invalid parameter");
pszPrev = TEXT("Undefined error");
MessageBox(NULL, pszPrev, TEXT(""), MB_OK);
Medical Web Viewer .NET
.NET, Java, Android, and iOS/macOS Assemblies
C API/C++ Class Libraries