Re: Dlls,memory allocation



Sundar wrote:
Hi,

i am trying to make an application that will require registering of
quite a few dlls and execute. Now one of the first bottlenecks that my
mentor refused is allocation of memory or the usage of mallocs in the
dlls. He tells me that for an application to run perfectly , there must
be no dynamic memory in the libraries.. I am not quite impressed..

Can anyone clear out this mess please?

This is a good idea not only for dlls but for
normal libraries too.

If you allocate memory in the library, it could be that the user thinks
he can free it. That would be catastrophic if your library was compiled
with another compiler and has another runtime free/malloc system than
what the user of the library is using.

You can only allocate memory if you also provide a means for freeing
the memory in your library. In that case, the allocation /freeing will
work. Whether it is a good practice it is another thing.

A cleaner interface is when the user makes all allocations/freeing
and your library uses the memory it is provided to work with: you
receive pointers to buffers, etc.
.



Relevant Pages

  • Re: EncryptMessage Memory leak
    ... You are correct about the dlls, ... I should say in any case that these two libraries are the main difference ... Yet memory continues to be leaked in the EncryptMessage call (I've proved ... these two dlls then I could see how you'd leak memory. ...
    (microsoft.public.platformsdk.security)
  • Re: Simple C containers, std::vector analog
    ... Possibly an artifact of your OS's memory handler. ... >standard C library dynamic heap memory allocation facility, ... For coding libraries in general, I suggest portability is more ...
    (comp.lang.c)
  • Re: Memory Management
    ... The program is a bunch of DLLs. ... I'm still using the CRT's malloc and free to allocate memory. ... If the application makes a memory allocation request, ... I have implemented a memory manager for some SDK I'm working on (a ...
    (microsoft.public.vc.language)
  • Re: Dlls,memory allocation
    ... quite a few dlls and execute. ... be no dynamic memory in the libraries.. ... In that case, the allocation /freeing will ...
    (comp.lang.c)
  • Re: More Flex issues
    ... It was distributed as part of the now-ancient RISC_OSLib library, and I believe in a newer incarnation is shipped as part of the Toolbox libraries with the Castle 'C' development tools. ... As you allocate memory your program's Wimp slot size will increase. ... Fragmentation occurs when free spaces open up as they might not be large enough to accommodate a subsequent allocation. ... Many applications attempt to get around this using Flex. ...
    (comp.sys.acorn.programmer)