Prev: FabToys et al
Next: Register problem Report Pro
From: Geoff Schaller on 10 Oct 2007 18:13 Peter, No, this is not good code. It is recursive and does formal mem allocs that cannot be cleared until all levels of recursion have ceased. It may be fast but you are in for significant trouble depending on what the other method calls do. This cannot be deduced from the code you do show. > I still don't understand why SetKidStackSize have no effect on this. Because this is not the only parameter you blow. What about Axits? You probably create too many K Ids. Perhaps you should inspect all memory options through each level of recursion and see which one blows up first. Also, look to what happens inside the other methods being called. What objects are involved there? This is very complex code. Do you really need all that pointer arithmetic? If it was strings I could understand it but dwords? Geoff
From: Armin Back on 11 Oct 2007 03:55 Hi Peter, changing your code a bit should solve your problem: > METHOD QuickSortDword( nCol AS DWORD, nStart AS DWORD, nStop AS > DWORD ) AS VOID PASCAL CLASS RamDbf .... .... .... > ENDIF > NEXT ==> MemFree( pTemp1 ) ==> MemFree( pTemp2 ) > IF pivot - nStart >= 2 > SELF:QuickSortDword( nCol, nStart, pivot-1 ) > ENDIF > IF nStop - pivot >= 2 > SELF:QuickSortDword( nCol, pivot+1, nStop ) > ENDIF > > RETURN Before doing a recursive call you should free the memory. HTH Armin
From: Peter Gargos on 11 Oct 2007 12:45 Hi Armin and Geoff, there is no memory alloc problem. I my case, _dwrecordsize is about 30 bytes. While sorting memory grows ( under taskmanager ), but not dramaticaly. If you move memfree, there is no difference. Geoff wrote "you probably create many kids". Yes, maybe, ( each method call ? ), MEMORY_STACKKID params grows, at value 675 comes error. ( I have SetStackKid at 32KB-1MB, default is 8kB ). Many method called, but I think that this is also not problem. For example - SELF:GoTo, SELF:Fieldget ..... These methods return params back and end. ( no any mysterious ways ). Inside others method, no any objects are created/used - respectively any dynamic vars not used. Goto method - params is dwRecno, return VOID _ptrRecordStartAt := PTR( _CAST, DWORD( _CAST, _ptrBuffers ) + ; ( ( _dwRecNo-1 ) * _dwRecordSize ) ) I know that quicksort is "recursive hungry", but it is no safe under VO ? Peter Gargos
From: Geoff Schaller on 11 Oct 2007 17:49
Peter. Method calls of themselves are not a problem as long as you have enough stack space. K Ids relate to the number of objects created so if you are not creating objects then this is not the problem. To find the problem is simple. For each recursion call, log the important memory parameters and see which one breaks. Look up Memory() in the help and report ALL the important and relevant values. Geoff "Peter Gargos" <pgargos(a)hotmail.com> wrote in message news:1192121132.183865.258010(a)50g2000hsm.googlegroups.com: > Hi Armin and Geoff, > there is no memory alloc problem. I my case, _dwrecordsize is about 30 > bytes. > While sorting memory grows ( under taskmanager ), but not dramaticaly. > If you move memfree, there is no difference. Geoff wrote "you probably > create many kids". Yes, maybe, ( each method call ? ), MEMORY_STACKKID > params > grows, at value 675 comes error. ( I have SetStackKid at 32KB-1MB, > default is 8kB ). > Many method called, but I think that this is also not problem. > For example - SELF:GoTo, SELF:Fieldget ..... These methods return > params back > and end. ( no any mysterious ways ). Inside others method, no any > objects are > created/used - respectively any dynamic vars not used. > > Goto method - params is dwRecno, return VOID > _ptrRecordStartAt := PTR( _CAST, DWORD( _CAST, _ptrBuffers ) + ; > ( ( _dwRecNo-1 ) * _dwRecordSize ) ) > > I know that quicksort is "recursive hungry", but it is no safe under > VO ? > > Peter Gargos |