Path: utzoo!attcan!utgpu!watmath!iuvax!cica!tut.cis.ohio-state.edu!purdue!bouma From: bouma@cs.purdue.EDU (William J. Bouma) Newsgroups: comp.lang.forth Subject: Re: Toy Forth Summary: memory management Keywords: fsh Message-ID: <8612@medusa.cs.purdue.edu> Date: 10 Nov 89 17:18:10 GMT References: <8538@medusa.cs.purdue.edu> <918@acf5.NYU.EDU> Organization: Department of Computer Science, Purdue University Lines: 25 In article <918@acf5.NYU.EDU> sabbagh@acf5.UUCP () writes: > >I would like to hear more about your efforts. In particular, how do you >handle the problem of not knowing how long a word defintion will be usin >dynamic memory? At present my policy is that I should only allocate as much memory as is needed. I use adjustable arrays for just about everything internal, including the stacks. Thus if a stack overflows I can query the user if he wants to grow it. When compiling a word, I begin with an array of some default size. If that overflows, I reallocate to a larger one. When done I reallocate to just the amount being used. If errors occur durring a compile, I free the whole array. The only problem with dynamic (de)allocation is the potential for memory fragmentation. I am not sure how much of a problem this will be in practice? For now, I don't worry about it, and just let the system memory manager do what it wants. There are other more noticeble changes as well. One can only 'forget' individual words and arrays, rather than a word and all that follows it in memory. ',' is not useful, so I have found other (better 8^) uses for the symbol. -- Bill || ...!purdue!bouma