answersLogoWhite

0


Want this question answered?

Be notified when an answer is posted

Add your answer:

Earn +20 pts
Q: When does OS allocate physical memory for variable “buffer”?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

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*


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.


What is the process of allocation of memory for an integer type variable?

To dynamically allocate memory, use the following function (stdlib.h I believe): int *variable1 = malloc(sizeof(int));


How do you use a pointer?

A pointer is a reference to a location in memory that is a primitive type in C and other low-level languages. An example use would be if you wanted to store data at run-time, you would have to allocate memory using the malloc function, an you would access that memory area using a pointer Example (modified from http://www.cplusplus.com/reference/clibrary/cstdlib/malloc): #include <stdio.h> #include <stdlib.h> int main () { int i,n; char * buffer; // Declare a pointer to a char printf ("How long do you want the string? "); scanf ("%d", &i); // Get input from user and store in i // Allocate space for i+1 characters buffer = (char*) malloc ( sizeof( char[i+1] ) ); // buffer should now contains a pointer to this location if (buffer==NULL) exit (1); // Memory allocation failed, abort for (n=0; n<i; n++) buffer[n]=rand()%26+'a'; buffer[i]='\0'; printf ("Random string: %s\n",buffer); free (buffer); // Release allocated memory return 0; }


Why you have to declare variable first in turbo c?

All variables (and constants) must be declared before they can be used. This is so the compiler knows exactly how much memory to allocate to the variable, as the declaration tells the compiler exactly what the variable's type is.


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.


How much maximum can you allocate in a single call to malloc?

I believe you can attempt to allocate as much as you want, but if you try to take more physical memory than your machine has then malloc will instead return a null pointer


What is a pointer in computer language?

A pointer is a variable whose value is the address to another variable. Pointers are most commonly used to dynamically allocate memory off of the heap instead of defining all of your variables at compile-time.


How you allocate the memory in java?

In Java we need not allocate memory manually. The JVM would take care of allocating as much memory that your objects would require automatically.


What can trigger a buffer overflow?

A buffer overflow occurs when a program attempts to write data to a buffer, but exceeds the boundaries of the buffer, similar to Java's "Array Out of Bounds Exception." This could happen with poorly written code that fails to check for the end of the buffer, or it could be exploited maliciously. One exploitative example would be a stack buffer overflow, in which data is copied to a local variable on the stack. But if the data is larger than the local variable can contain, the extra data will "spill over" onto nearby memory. This would allow one to overwrite data that was not intended to be altered.


What are the different function used for dynamic memory allocation?

alloc :- to allocate memory. calloc :- to free the memory.