RE: TK_mem problem and replacement
- Posted by Derek Parnell <Derek.Parnell at SYD.RABOBANK.COM> Jun 24, 2002
- 381 views
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01C21BE3.CDC21510 charset=iso-8859-1 Thanks Matt and Jordah for this discussion. Matt is essentially correct on this one. a) There will be provision for larger data types in the future. b) The minium allocation is always 4 bytes, even if you ask for less. This is mainly for performance reasons. c) I should return zero if an unknown datatype is used. d) Bernie is wrong about RAM acquired by win32lib being locked up if a win32lib app crashes. It is true that RAM acquired some other way might still be held if the app crashes, but that's not due to any action in win32lib. AFAIK, all RAM acquired by win32lib is released by Windows if the app crashes. e) Win2lib takes memory from Windows in 16,000 byte chunks (heaps). It doles out RAM from these heaps. If there is not enough RAM in the current heaps, it gets enough new heaps to make up what is asked for. When release_mem() frees up an allocation and if that freeing up, also frees up any heaps, these heaps are returned to Windows for reuse in this or other apps that might be running. Hope this helps. ----------------- Derek. > -----Original Message----- > From: jordah ferguson [mailto:jorfergie03 at yahoo.com] > Sent: Tuesday, 25 June 2002 2:57 > To: EUforum > Subject: TK_mem problem and replacement > > > > Hi Derek, > > > B4, you read this, i have written a tk_mem.e replacement but > using pure > euphoria code. It is fast and is still undergoing a series of > tests. It > is safer and faster than the original tk_mem. Soon to be > released on RDS > > > I was Checking tk_mem.e code and found out something rather > unusual in > acquire_mem, > here check out this code. > > constant vSizeNames = {Byte, Word, Long, Lpsz, Hndl, HndlAddr, Strz} > constant vSizeLengs = { 1, 2, 4, 4, 4, 4, 1} > > --** START: FROM ACQUIRE_MEM() > > -- Check for special datatype "names" > if pData < 0 then > pData = find(pData, vSizeNames) > if pData != 0 then > pData = vSizeLengs[pData] > end if > end if > --### Problem!!! Below > -- What if you are allocating a Byte,Strz or Word? They would still be > -- forced to take 4 bytes of memory with below code > > if pData < 4 then > pData = 4 > end if > > --** END: FROM ACQUIRE_MEM() > > If Yes, pData should be a minimum of 4 Bytes. Why bother with > > if pData != 0 then > pData = vSizeLengs[pData] > end if > > Derek, PLease check on this and i hope, It doesn't cause any problems. > > Cheers, > Jordah Ferguson > aka Sir LoJiK > > > > ================================================================== De informatie opgenomen in dit bericht kan vertrouwelijk zijn en is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onterecht ontvangt wordt u verzocht de inhoud niet te gebruiken en de afzender direct te informeren door het bericht te retourneren. ================================================================== The information contained in this message may be confidential and is intended to be exclusively for the addressee. Should you receive this message unintentionally, please do not use the contents herein and notify the sender immediately by return e-mail. ================================================================== ------_=_NextPart_000_01C21BE3.CDC21510 Content-Type: application/ms-tnef