[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference hydra::amiga_v1

Title:AMIGA NOTES
Notice:Join us in the *NEW* conference - HYDRA::AMIGA_V2
Moderator:HYDRA::MOORE
Created:Sat Apr 26 1986
Last Modified:Wed Feb 05 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:5378
Total number of notes:38326

2801.0. "Memory Defragmentation" by KYOA::MIANO (O.K. so who cares about the METS?) Mon Aug 07 1989 00:36

I am working on an application written in C that uses a lot of stack
storage.  I'm not sure how much right now but it may be in the 1-200,000
range.  Unfortunately the Lattice Debugger has a bug that allows you to
only access 1/4 of your stack.  This means that while debugging I need
to set the stack from 4-800,000.  This would be all right since I have
a 2500 with 3 Mbs except for one problem: memory fragmentation.  With
the stack set to 800,000 often a process gets completely stuck.  You
can't even run the stack program even though there are 2.5Mbs of free
memory. 

My questions are:

1) Is is possible to deframent the Amiga's memory.  Is it possible the
the OS may break the memory into chunks that may be contigouos but the OS
cannot combine adjacemt chuncks?
2) Can anyone recommend a good tool for memory defragmentation?

John
T.RTitleUserPersonal
Name
DateLines
2801.1Exec does defragmentationTLE::RMEYERSRandy MeyersMon Aug 07 1989 01:3720
Re: .0

Sorry, the Exec already does memory defragmentation when memory is
deallocated.  The cause of fragmentation is small bits of memory that
really are allocated and prevent regions from coalescing.

(Well, there is one type of unnecessary memory fragmentation.  The
autoconfig code will not coalesce memory from two separate memory
boards even if the memory does really form a big contiguous chuck
of your address space.  So if you have separate memory boards, or
you have a 8 Meg board with 6 Meg installed, you could experience
this type of fragmentation.  ASDG wrote a public domain utility to
remedy fragmentation due to autoconfig.)

About the only thing you can do is make a boot floppy with your
application on it, and try to get into your program as soon as
possible.  Don't use any ram disks.  Don't do any assigns.  Don't
load the Workbench.  Don't run any screen blankers or "pop up"
programs.  Don't (or try not to) do anything that uses memory before
running your program.
2801.2Do your own alloc()FROCKY::BALZERChristian Balzer DTN:785-1029Mon Aug 07 1989 05:139
    There was a fine article about this topic by one of the Amiga engineers
    on UseNet quite a while ago. I'll check if I can locate it.
    What it basically boils down to is to have your program allocate
    a sufficiently large chunk of memory and do all the tiny allocs
    with a custum alloc function from this pool. If you exit the
    application fragmentation will be minimal.
    
    Regards,
    <CB>
2801.3Right answer, different question?TLE::RMEYERSRandy MeyersMon Aug 07 1989 18:0133
Re: .2

I think you've answered a different question, Christian.  The problem is
that all the other programs in the system have fragmented memory,
and so there isn't memory enough for the user written application
to start.  

The author of .0 was looking for something to do to the other
programs in the system to keep them from leaving memory fragmented.

>    What it basically boils down to is to have your program allocate
>    a sufficiently large chunk of memory and do all the tiny allocs
>    with a custum alloc function from this pool. 

I think the problem here is that the Exec will gladly carve memory up
into tiny chunks for tiny allocation requests.  As long as those
chunks remain allocated, the system memory pool will look like
Swiss cheese.  However, then those chucks are deallocated, the
Exec will coalesce them back together.  The scheme you've described
allows an application that allocates lots of little chunks to
run at the same time as an application that needs a few very big
chunks.

>    If you exit the application fragmentation will be minimal.

As I said before, if you deallocate the memory, it get coalesced.
The problem comes if you don't deallocate it, or somebody else
needs to run at the same time with you.

>    There was a fine article about this topic by one of the Amiga engineers
>    on UseNet quite a while ago. I'll check if I can locate it.

Please do.  I would be interesting reading.