answersLogoWhite

0


Best Answer

No. Memory is allocated for each unique constant rather than to each individual constant. However, compilers do not physically allocate memory; the constants are allocated in the program's data segment at linktime. The actual allocation within memory occurs at loadtime, when static memory is physically allocated to the executable. Constants are then initialized using information found in the program's data segment.

User Avatar

Wiki User

8y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Does a compiler allocate memory space for each constant?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Can an application or devce driver specify if it will use physical memory or the swap file for its data?

No, because the O/S call to allocate memory can allocate either physical memory OR swap file space. It's under O/S control, not the application.


What are the advantages and disadvantages of the linked implementation of a queue relative to the contiguous implementation?

Contiguous implementation (e.g., using an array), has a major disadvantage in that you have to allocate enough space in the array to hold all the elements in the queue. When there is insufficient space, you have to re-allocate, which may occasionally require the entire array be copied to new memory. In addition, with each extraction, you are left with unused memory at the start of the array. Thus before any re-allocation, you must first check if there are unused elements and then shunt all elements forward, thus creating space at the end of the array. If we ignore the shunting and re-allocations necessary with an array, insertions and extractions will occur in constant time for both contiguous and linked implementations. However, once you take shunting and re-allocation into account, we find that contiguous implementations occasionally falter during an insertion. Contiguous implementations also require more memory than linked implementations. Although a linked node is larger than an array element by one pointer (32 bits on a 32-bit system), contiguous implementations must allocate far more memory than is actually required in order to minimise the number of re-allocations. Thus an array must always have unused elements. Moreover, when all elements are extracted from the queue, the current allocation remains in memory. With linked implementations, the only memory allocated is the memory actually in use at any given moment, with the minimum memory requirement being just one pointer, to the tail node. An optimal queue implementation will use a circular linked list, where only the tail node need be maintained by the list object. The tail's next node always points to the head node, so there is no need to maintain this separately. The only real disadvantage of a linked implementation is the need to allocate and deallocate memory for each insertion and extraction respectively. However, this is a constant time operation. With contiguous implementation, only extraction is guaranteed to be a constant time operation. Most of the time, insertions will be constant time, but will occasionally take variable time due to the need to shunt or re-allocate.


How the new operator works in java?

1. It is the only way to create object. 2. New is a keyword. 3. New operator allocates memory for an object. 4. It is a bit faster and clever way of creating objects or instances.


How can we create an unsized array to c programme?

Use a pointer... int a*; a = malloc(sizeof(int)*100); //allocate space for 100 elements free(a); a = malloc(sizeof(int)*1000); // allocate space for 1000 elements free(a);


How do you determine the size of a structure?

Add up the sizes of the individual pieces, plus the slack space between them that might be there (depending on the computer, compiler, and options) for memory alignment purposes. In C or C++, you can usually use the sizeof() operator to determine this.

Related questions

Who takes more memory space interpreter or compiler?

Interpreters


Who will take more memory space compiler or interpreter?

Interpreters


How would you define variable in c?

variable is a name that allocates the memory space where you store some data Hardly. Names do not allocate memory space *sigh*


What are the three major activities of an operating system with regard to memory management?

1- keeping track of which parts of memory are currently being used and by whom.2- decide which process is to be loaded in memory when the space is available.3- allocate and deallocate memory space as needed.


Can an application or device driver specify if it will use physical memory or the swap file for its data?

No, because the O/S call to allocate memory can allocate either physical memory OR swap file space. It's under O/S control, not the application.


Can an application or devce driver specify if it will use physical memory or the swap file for its data?

No, because the O/S call to allocate memory can allocate either physical memory OR swap file space. It's under O/S control, not the application.


How much space could you allocate for unlimited RAM?

RAM (Random Access Memory) is a physical chip that is inserted into your motherboard inside your computer. Allocating 'space' on your computer to act as RAM is called 'virtual memory'. Virtual memory can be increased as long as you have room on your hard drive to allocate. Physical memory can be increased by replacing the chips on your motherboard. Quite simply, to allocate an unlimited amount of space for RAM would only depend on how large your hard drive(s) were or how many slots on your motherboard existed.


What are 3 major activities of an os regard to memory management?

1.keeping track of which parts of memory are currently being used and by whom. 2.decide which process is to be loaded in memory when the space is available. 3.allocate and deallocate memory space as needed.


Why does your computer keep saying this game is out of memory?

The computer probably keeps saying that the game is out of memory because the amount of space that your computer has allocated on the hard drive for that game has been filled. You will most likely be able to find away to allocate more memory space to the game you are playing by watching a 'How To' video on YouTube.


What are the advantages and disadvantages of the linked implementation of a queue relative to the contiguous implementation?

Contiguous implementation (e.g., using an array), has a major disadvantage in that you have to allocate enough space in the array to hold all the elements in the queue. When there is insufficient space, you have to re-allocate, which may occasionally require the entire array be copied to new memory. In addition, with each extraction, you are left with unused memory at the start of the array. Thus before any re-allocation, you must first check if there are unused elements and then shunt all elements forward, thus creating space at the end of the array. If we ignore the shunting and re-allocations necessary with an array, insertions and extractions will occur in constant time for both contiguous and linked implementations. However, once you take shunting and re-allocation into account, we find that contiguous implementations occasionally falter during an insertion. Contiguous implementations also require more memory than linked implementations. Although a linked node is larger than an array element by one pointer (32 bits on a 32-bit system), contiguous implementations must allocate far more memory than is actually required in order to minimise the number of re-allocations. Thus an array must always have unused elements. Moreover, when all elements are extracted from the queue, the current allocation remains in memory. With linked implementations, the only memory allocated is the memory actually in use at any given moment, with the minimum memory requirement being just one pointer, to the tail node. An optimal queue implementation will use a circular linked list, where only the tail node need be maintained by the list object. The tail's next node always points to the head node, so there is no need to maintain this separately. The only real disadvantage of a linked implementation is the need to allocate and deallocate memory for each insertion and extraction respectively. However, this is a constant time operation. With contiguous implementation, only extraction is guaranteed to be a constant time operation. Most of the time, insertions will be constant time, but will occasionally take variable time due to the need to shunt or re-allocate.


How the new operator works in java?

1. It is the only way to create object. 2. New is a keyword. 3. New operator allocates memory for an object. 4. It is a bit faster and clever way of creating objects or instances.


A variable declaration tells the operating system to allocate space?

In RAM