Professional Documents
Culture Documents
Types of Memory Fragmentation
Types of Memory Fragmentation
1. Overhead
2. Internal Fragmentation
3. External Fragmentation.
When blocks of memory are allocated during runtime, it is highly unlikely that these released
blocks of memory will again form continuous large memory blocks. Hence, the free memory
gets interspersed with the blocks of memory in use. The average size of blocks of memory
consequently becomes quite small. This problem, coupled with incomplete usage of the allocated
memory, results in memory fragmentation.
For example, consider a system having 5 MB total memory. Let the total free memory be 2 MB
which the programs could use at runtime. However, due to interspersed free and used memory
blocks the user is not able to allocate even 1 MB of free space for a new program as all the free
memory blocks are not larger than 500 KB. Also, if in the 3 MB allocated memory only 2 MB is
used then the remaining 1 MB memory goes unused. This wastage of space is the major problem
of internal and external memory fragmentation.
Overhead
The memory allocator needs to store all the information related to all memory allocations.
This information includes the location, size and ownership of any free blocks, as well as other
internal status details. Overhead comprises all the additional system resources that the
programming algorithm requires. A dynamic memory allocator typically stores this overhead
information in the memory it manages. This leads to wastage of memory. Hence, it is considered
as a part of memory fragmentation.
Internal fragmentation
When the memory allocated is larger than required, the rest is wasted. Some reasons for excess
allocation are:
The term "internal" refers to the fact that the unusable storage is inside the allocated region.
while this may seem foolish, it is often accepted in return for increased efficiency or simplicity.
There are some basic memory allocation rules which all memory allocators must adhere to.
According to the "segregated free list" allocator policy, all memory allocations must start at an
address divisible by 4, 8, or 16. The memory allocator may assign blocks of only certain
predefined sizes to clients. It depends upon the processor architecture. Also, extra bytes are
assigned to a program for alignment and metadata.
Or in many file systems, each file always starts at the beginning of a cluster because this
simplifies organization and makes it easier to grow files. Any space left over between the last
byte of the file and the first byte of the next cluster is a form of internal fragmentation called file
slack, slack space, or cluster overhang. Slack space is a very important source of evidence in
computer forensic investigation. Unlike other types of fragmentation, internal fragmentation is
difficult to reclaim; usually the best way to remove it is with a design change. For example, in
dynamic memory allocation, memory pools drastically cut internal fragmentation by spreading
the space overhead over a larger number of objects.
External fragmentation
External fragmentation is the inability to use free memory as the free memory is divided
into small blocks of memory and these blocks are interspersed with the allocated memory. It is a
weakness of certain storage allocation algorithms, occurring when an application allocates and
deallocates ("frees") regions of storage of varying sizes, and the allocation algorithm responds by
leaving the allocated and deallocated regions interspersed. The result is that although free storage
is available, it is effectively unusable because it is divided into pieces that are too small to satisfy
the demands of the application. The term "external" refers to the fact that the unusable storage is
outside the allocated regions.
Note that MASM32 will not install on a network drive. MASM32 comes with its own
runtime library written fully in assembler and an extensive range of macros for improved high
level emulation and faster development. It builds its own IMPORT libraries for the Windows
API functions and supplies its own include files for a very large number of API functions.
The default editor in MASM32 has been fully recoded from scratch in MASM and it is
smaller, faster and more powerful with two (2) separate scripting engines, a legacy version to
maintain backwards compatibility of existing scripts and a completely new one that is much
faster and more powerful than its predecessor.
New CHM documentation and a wider range of "Create New" project types directly
supported by the new script engine from the editor place a wider range of project types at your
fingertips. There is also a new format PLUGIN system for the default editor as well as the old
one for backwards compatibility.
UNICODE Support
The MASM32 SDK has a completely new include file system that supports either ASCII
or UNICODE by the inclusion of an equate, __UNICODE__ . Two new macro systems support
UNICODE text that can be used in much the same manner as embedded ASCII text.
DEP Compatibility
The MASM32 SDK has been rebuilt to ensure it is fully compatible with the Data
Execution Prevention safety feature in later versions of Windows.
OS Version
The MASM32 SDK requires Win2000 or higher Windows versions. The Installation is
not designed to run on Win9x or ME.
Features
1. The most up to date version of Ray Filiatreault's floating point library and tutorial.
2. A completely new dedicated time and date library written by Greg Lyon.
3. The MASM32 library with over 200 procedures for writing general purpose high performance
code.
4. A new dynamic array system for variable length string and binary data with both a macro and
procedural interface.
5. The include files and libraries have been upgraded to include VISTA / Win7 with additional
equates and structures.
6. A specialised linker, resource compiler and assembler from Pelle's tool set with working
examples.
7. An extensive range of example code ranging from simple examples to more complex code
design.
8. Prebuilt scripts in the editor for creating working templates for assembler projects.
9. A very easy to use console interface for developing algorithms, test code and experimental
ideas in code.
Application
MASM is routinely capable of building complete executable files, dynamic link libraries
and separate object modules and libraries to use with the Microsoft Visual C development
environment as well as MASM. It is an esoteric tool that is not for the faint of heart and it is
reasonably complex to master but in skilled hands it has performance that is beyond the best of
modern compilers when properly written which makes it useful for performance critical tasks.
4 + 1 > 8 6 ? 4 + 1 8 6 : 8 6 4 + 1
which gives a unexpected result.
Nested Macro Invocations:
Nested macro invocation statement like
DISPLAY (ABSDIFF (3,8)) would be expanded to
Printf (ABSDIFF (3,8) =%d \n, ABSDIFF (3,8))
After rescanning, would be
printf (ABSDIFF (3,8) =%d\n, ((3) > (8) ? (3) (8) : (8) (3))
when executed, the display would be
ABSDIFF (3,8) = 5.
Macro Conditional Statements:
# ifndef BUFFERSIZE
# define BUFFERSIZE 1024
# endif.
which means if buffersize is not defined, buffersize is defined to 1024. Similar macro
conditional statements can be used to check for errors like subscript errors and so on.
System software is computer software designed to operate the computer hardware and to
provide a platform for running application software. The most basic types of system software
are:
Device drivers such as computer BIOS and device firmware; these provides basic
functionality to operate and control the hardware connected to or built into the computer.
The operating system (prominent examples being Microsoft Windows, Mac OS X and
Linux), which allows the parts of a computer to work together by performing tasks like
transferring data between memory and disks or rendering output onto a display device. It
also provides a platform to run high-level system software and application software.
Servers, in this context, are computer programs running to serve the requests of other
programs, the "clients". The server performs some computational task on behalf of clients
which may run on either the same computer or on other computers connected through a
network.
Utility software, which helps to analyze, configure, optimize and maintain the computer.
Window systems are components of a graphical user interface (GUI), and more
specifically of a desktop environment, which supports the implementation of window
managers, and provides basic support for graphics hardware, pointing devices such as
mice, and keyboards. The mouse cursor is also generally drawn by the windowing
system.
In some publications, the term system software is also used to designate software
development tools (like a compiler, linker or debugger).