All,
What will happen if I create handle in the app but don't call MemPtrFree when the
app leaves?
Will there memory leak occur?
Charles
Greg Winton wrote:
> At 09:40 AM 1/1/00 -0500, you wrote:
> >i have some functions which have some big buffers (1000 char array's). the
> >arrays are only used at the top of these branches as buffers for incoming
> >information and such and are parsed into structs before leaving. i had my
> >stack blow up though because of this but got around it using static
> >char[1000]'s. would it be more beneficial to MemPtrNew them then release it
> >when i'm done? or am i handling it alright as it is?
>
> Allocated memory is better than statics because you can access the memory
> no matter how your app is launched. In some cases you will have no access
> to global data (which includes statics). Also, should you decide to
> modularize your app and put this code in a shared library, you will
> definitely have no access to static data.
>
> I'd recommend allocating them at the start using MemHandleNew,
> locking/unlocking them as needed using MemHandleLock and MemHandleUnlock
> respectively, then freeing them when you're done using MemHandleFree.
>
> Allocating a handle rather than a pointer gives the OS the ability to move
> the blocks around when they are not in use. This might not apply to much
> to the scenario you describe where you only use the blocks for the duration
> of the function, in which case MemPtrNew and MemPtrFree would be fine.
>
> My $0.02.
>
> Greg
> Greg Winton
> Bachmann Software and Services, LLC
> mailto:[EMAIL PROTECTED]
> http://www.bachmannsoftware.com