Where exactly are the variables stored in a C program? -


i new computer programming. studying variables , came across definition on internet:

variables names give computer memory locations used store values in computer program.

what these memory locations? these locations refer actual computer memory or dump in program calls variables later when need them? there other terms encountered here on stack overflow heap , stack. not head around these. please help.

the way you've asked question suggests expect single answer. not case.

in rough sense, variables exist in memory while program being executed. memory variables exist in depends both on several things.

modern computer hardware has quite complex physical memory architecture - multiple levels of cache (in both cpu, , various peripheral devices), number of cpu registers, shared memory, different types of ram, storage devices, eeproms, etc. different systems have these types of memory - , more types - in different proportions.

operating systems may make memory available program in different ways. example, may provide virtual memory, using combination of ram , reserved hard drive space (and managing mappings, program can't tell difference). can allow program use more memory physically available ram, affects performance, since operating system must swap memory usage of program between ram , hard drive (which typically orders of magnitude slower).

a lot of compilers , libraries implemented maximise programs performance (by various measures) - compiler optimisation of code (which can cause variables in code not exist when program run), library functions crafted performance, etc. 1 consequence of compiler, or library, may use memory in different ways (e.g. implementations may embed code in executable detect memory resources available when program run, others may assume fixed amount of ram), , usage may vary on time.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -