Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!pt.cs.cmu.edu!cive.ri.cmu.edu!hmp From: hmp@cive.ri.cmu.edu (Henning Pangels) Newsgroups: comp.realtime Subject: Memory management under VxWorks Keywords: VxWorks, memory fragmentation, programmer frustration Message-ID: <8136@pt.cs.cmu.edu> Date: 23 Feb 90 15:33:29 GMT Organization: Carnegie-Mellon University, CS/RI Lines: 35 The problem of memory fragmentation under vxWorks has been discussed in this group before, I know, but I'm curious if anyone has found a workaround, if not an outright solution by now. The general problem I'm seeing is that frequent use of malloc() and free() leads to more and more fragmentation, eventually causing an exception when the largest chunk of memory isn't large enough for a particular operation. While it is somewhat possible to control explicit use of these calls in application code, they also seem to be used by many system calls that create and delete system objects like sockets, semaphores etc. A simple experiment shows that socket(AF_INET,SOCK_STREAM,0), for example, makes 6 calls to malloc(), using up a total of 140 bytes. Now, if the answer is that you just shouldn't be creating and deleting these things on a regular basis, what good is having dynamic memory allocation in the first place? If you knew beforehand exactly what and how many data objects your application needed, you'd just allocate them statically in your code. An approach I've thought about is to create the objects you need when you need them, and reuse them from then on whenever possible. In a way, that amounts to writing you own memory manager, which is something an application really shouldn't have to deal with. Another idea is to play with memory pools, but as far as I can see, there is no way to have system calls allocate memory out of anything but the system pool. Do others out there continue to run into this problem, too? How about Wind River? Any comments or promises of future enhancements in this area? -- Henning Pangels Field Robotics Center ARPAnet/Internet: hmp@cive.ri.cmu.edu Robotics Institute (412) 268-7088 Carnegie-Mellon University