Sets the memory allocation method used in the dicom library.
#include "ltdic.h"
L_LTDIC_API L_UINT16 EXT_FUNCTION L_DicomSetMemoryAllocation(nType)
Type of memory allocation. Possible values are:
Value | Meaning |
---|---|
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. |
Value | Meaning |
---|---|
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_INT DicomSetMemoryAllocationExample(L_VOID)
{
L_UINT16 uRet;
L_TCHAR *pszPrev = TEXT("");
uRet = L_DicomSetMemoryAllocation(MEMORY_GLOBAL);
switch(uRet)
{
case MEMORY_FAR:
pszPrev = TEXT("Previous memory allocation method: malloc");
break;
case MEMORY_GLOBAL:
pszPrev = TEXT("Previous memory allocation method: GlobalAlloc");
break;
case MEMORY_FAIL:
pszPrev = TEXT("L_DicomSetMemoryAllocation failed--invalid parameter");
break;
default:
pszPrev = TEXT("Undefined error");
}
MessageBox(NULL, pszPrev, TEXT(""), MB_OK);
return DICOM_SUCCESS;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.