answersLogoWhite

0


Best Answer

Dynamic memory allocation is at runtime. static memory allocation is before run time, but the values of variables may be changed at run time.

Static memory allocation saves running time, but can't be possible in all cases.

Dynamic memory allocation stores it's memory on heap, and the static memory allocation stores it's data in the "data segment" of the memory.

User Avatar

Wiki User

16y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

A static array is instantiated at compile time and exists for the entire duration of a program. The amount of memory allocated to a static array is fixed and cannot be altered at runtime. The memory resides in the program's data segment (the stack). A dynamic array is instantiated at runtime and exists from the point of instantiation until it is manually released back to the system. Failure to maintain at least one pointer to the memory will result in a memory leak. The amount of memory allocated is variable and can be altered at runtime. The memory resides in the free store (the heap). Unlike all static and all one-dimensional arrays, multi-dimensional arrays need not reside in contiguous memory. Each dimension can be split into multiple one-dimensional arrays using one-dimensional arrays of pointers and pointers to pointers.

This answer is:
User Avatar


User Avatar

Wiki User

11y ago

In VB6 you have two different kinds of arrays, static and dynamic.

The key difference between static and dynamic arrays is that you can't change the size of a static array. VB.NET supports both syntax forms, but in all cases it creates dynamic arrays.

However, there is another, less obvious difference between static and dynamic arrays under VB6, which becomes apparent when you apply the Erase keyword to the array. When you erase a static array all the array elements are reset to zero, empty string, or nothing; when you erase a dynamic array all items are destroyed and you can't access any element until you REDIM-ension the array.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

Dynamic array size can be changed while size of static array can't be changed.

Dynamic array is defined with empty parentheses, while static array is defined with subscript in parentheses.

In Dynamic array memory is allocated on demand (i.e. when needed) while on static array memory is allocated when the variables are created. (Sometimes you might have observed that your array size is less but the program is compiled correctly) that is nothing but dynamic array.

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

Static allocations exist for the entire duration a program is running. The amount of memory required for static variables is fixed size and is determined at compile time. The allocation itself occurs at load time based upon information found in the program's data segment. In simplistic terms, the data segment is part of the executable file itself and is loaded alongside the text segment which contains all the program code. The data segment has several regions to cater for constants, global variables and static variables, divided into initialised and uninitialised data. The program loader uses the information in the data segment to determine the amount of memory to allocate and where to allocate each datum.

Dynamic allocations occur at runtime in a region of memory known as the heap. Normally, a program will request additional memory from the heap via the operating system's memory manager on an as-required basis. However, requesting memory from the operating system has a runtime cost in terms of performance. To alleviate this, programs often provide their own memory manager which will make a one-time request for a chunk of contiguous memory which it can then use as it sees fit, allocating additional chunks as and when required, thus reducing the number of low-level system calls. However, all dynamic allocations must be returned to the system as soon as they are no longer required. This means the program must keep track of every allocation at all times. Failure to keep track of dynamic allocations will result in resource leaks and (ultimately) in running out of memory altogether.

There is also a third region of memory known as the call stack (or simply the stack). Every thread in a process has its own call stack and is used to keep track of functions: return addresses; arguments; local variables and; exception handlers. Each call stack is fixed size (determined at compile time) and is allocated at runtime whenever a thread loads (every process has at least one thread). The call stack usually resides at the top of the virtual address space and grows down into lower addresses.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

The main diff. Is dat static is constant while dynamic is prone to change

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

The memory allocated at runtime is dynamic memory allocation and the memory allocated during coding is static memory allocation.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Difference between static array and dynamic array?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Biology

What structure within the cell consists of pinwheel array of 9 triplets of microtubules to form a hollow tube?

the electron microscope has revealed that one of the components within the cell consists of pinwheel array of 9 triplets of microtubules arranged to form a hollow tube. this is what structure


What does CG stand in genomes?

It depends on if you're referring to CG as an acronym or just a general reference to the genome. C, or cytosine, and G, or guanine, are two of the four bases that are the building blocks of DNA. An individual's genome, or his or her complete DNA code, is a series of these four bases. The other two are adenine (A) and thymidine (T). Using "CG" in a different way, microarray technology is sometimes referred to as aCGH, which stands for "array comparative genomic hybridization". Microarray technology allows for the comparison of a test DNA sample against a partial control genome. This genome is represented by an array of probes, which are small pieces of DNA. How many probes one has in an array and which parts of the genome are represented customize the array to help a researcher/clinician interrogate the control sample for certain differences. They can be helpful in finding deleted or duplicated DNA material, for example.


Difference between colonial organisms and filamentous organisms?

The main difference is that filamentous organisms are thread-like in structure, such as fungi and algae. Colonial organisms are those that live in colonies to survive.


Biological function of protein?

Protein helps create and build healthy body tissue. Protein also has an array of amino acids and essential fatty acids that help with brain function.


What is type b ultrasound?

In B-mode ultrasound, which is the most common use, a linear array of transducers simultaneously scans a plane through the body that can be viewed as a two-dimensional image on screen.

Related questions

What is the difference between queues and circular queues?

A queue can use a dynamic array, or a linked list, but if using static memory, the queue becomes a circular queue because the underlaying data structure is a static circular array. This means the ends of the array are attached.


What is the difference between a fixed size array and a variable size array?

The obvious answer is that one has a constant size while the other does not. More specifically, a fixed-size array is one where the size is known at compile time and does not change at runtime. By contrast, the size of a variable-sized array may or may not be known at compile time but may change at runtime. We often refer to a variable-size array as being a dynamic array, however some people (myself included) incorrectly refer to a fixed-size array as being a static array. The misunderstanding largely comes from the fact that we often refer to the heap (or free store) as being dynamic memory because all dynamic variables are allocated there (including variable-size arrays). But the term dynamic array does not refer to the memory, it refers to the dynamic -- as in changeable -- nature of the array itself. By contrast, a fixed-size array is only deemed static if it is statically allocated, in which case it will be allocated in the program's data segment along with all other static variables, global variables and constants. But a local fixed-size array is allocated on the program's stack and is therefore, by definition, non-static. Moreover, you can allocate a fixed-size array on the heap!


Which condition is not necessary in dynamic stack?

in dynamic stack we don't have to initialize the size of array while in static stack we have 2 initialize it ......


What is static array and dynamic array in visual basic?

Generally speaking, a static array is a fixed-length array while a dynamic array is a variable-length array. However, we prefer the terms fixed-length and variable-length because static objects are objects that are allocated in static memory at compile time, which means they have a fixed offset address (the offset remains the same for each execution and will not change at runtime). Dynamic objects, on the other hand, are allocated and destroyed at runtime, which means they have dynamic addresses; each time the object is instantiated we cannot guarantee it resides at the same address. To put it another way, all static arrays must be fixed-length arrays, but not all fixed-length arrays must be static arrays. We can allocate a fixed-length array in static memory (in which case it is also a static array), but we can also allocate a fixed-length array on the call stack or on the heap, in which case we can potentially create more than one instance of that array, each with its own unique address. Consider a recursive function that instantiates a local (non-static) fixed-length array: each instance of that function would instantiate a new instance of that array, each with its own unique address. Similarly with multi-threaded applications: each thread has its own call stack, thus we could potentially have multiple threads invoking the same function and thus instantiating multiple instances of the same array in different call stacks, each with its own unique address. And if we allocate a fixed-length array on the heap, we have no guarantee where that array will be allocated. So whenever we speak of static or dynamic allocations, remember that we are specifically referring to the address (or at least the offset address). Dynamic addresses can change at runtime, static addresses cannot. Although the physical address of a static object can change between executions, its offset address (relative to the start of the static data segment) can never change -- not without recompiling the executable.


What static array and dynamic array in visual basic?

Generally speaking, a static array is a fixed-length array while a dynamic array is a variable-length array. However, we prefer the terms fixed-length and variable-length because static objects are objects that are allocated in static memory at compile time, which means they have a fixed offset address (the offset remains the same for each execution and will not change at runtime). Dynamic objects, on the other hand, are allocated and destroyed at runtime, which means they have dynamic addresses; each time the object is instantiated we cannot guarantee it resides at the same address. To put it another way, all static arrays must be fixed-length arrays, but not all fixed-length arrays must be static arrays. We can allocate a fixed-length array in static memory (in which case it is also a static array), but we can also allocate a fixed-length array on the call stack or on the heap, in which case we can potentially create more than one instance of that array, each with its own unique address. Consider a recursive function that instantiates a local (non-static) fixed-length array: each instance of that function would instantiate a new instance of that array, each with its own unique address. Similarly with multi-threaded applications: each thread has its own call stack, thus we could potentially have multiple threads invoking the same function and thus instantiating multiple instances of the same array in different call stacks, each with its own unique address. And if we allocate a fixed-length array on the heap, we have no guarantee where that array will be allocated. So whenever we speak of static or dynamic allocations, remember that we are specifically referring to the address (or at least the offset address). Dynamic addresses can change at runtime, static addresses cannot. Although the physical address of a static object can change between executions, its offset address (relative to the start of the static data segment) can never change -- not without recompiling the executable.


What is array in structures?

array is used to store the ame datatypes syntex: int array[]=new int[size]; dynamic declaration of array insertion array[1]=20; 2nd way: int array[]={10,20,30}; *important:- int array[20]={20,30,49,....} this way is wrong in java as this is static way and in java all is done dynamically


What is the difference between null array and an empty array?

There is no null array as such. However, a pointer to an array may be nullified (pointing to zero) before memory is allocated to it, or after that memory is released. But the same is true of any pointer. That is, the pointer is NULL, not what it previously pointed to. An empty array usually refers to a dynamic array for which no memory has yet been allocated (in other words, a null pointer). However, the term can also apply to static arrays or dynamic arrays that have been allocated memory, where every element is initialised with a value that has no significance. For instance, an array of natural numbers (positive integers greater than 0) might be initialised with the value 0 (a non-natural number) in every element to indicate that the array is empty. By contrast, individual elements could be set to zero to indicate which elements are available (an empty element as opposed to an empty array).


Can array be initialized if they are static?

Yes.


What is the difference between numeric array and associative array?

Numeric array has numbers(+integers) that represent the values Associative array has strings that represent the values


What are the types of array?

There are several different types of arrays, which describe the characteristics of the array. Arrays may be static or dynamic. Static arrays have a predetermined size that will not change over the course of the program's life cycle, while dynamic arrays may be made larger or smaller as necessary while the program runs. Arrays may be one-dimensional or multi-dimensional. An array of just one dimension stores values in a straight line, while a multi-dimensional array represents data that might be rectangular, such as the dots in an image, or even 3 dimensional, such as a multi-layer image, an animation, etc.


What is the difference between array and string of array?

When we declare an array of characters it has to be terminated by the NULL , but termination by NULL in case of string is automatic.


Difference between vector and array list?

Vectors are thread safe but array lists are not. Hence array lists are faster than Vectors.