How exactly is memory divided in C?

Updated on technology 2024-02-08
6 answers
  1. Anonymous users2024-02-05

    First of all, if you are wrong, if the value type is a global or static variable, it is assigned on the heap, and the local variable is allocated on the stack. The reference type is allocated on the heap, because the new comes out of the dynamically allocated memory, so both local and global are in the heap until the garbage user goes to it. In fact, memory allocation is basically the same form, and it has nothing to do with the language.

  2. Anonymous users2024-02-04

    I've been working for four years and don't particularly understand the memory partition of C. Personal understanding:

    public static class A static field in a static class is always present in memory, similar to a global variable.

    public static string username="";

    The value type is updated by a parameter without changing the original value, and can be considered a separate number. If the value is not updated if ref or out is not updated, the original value cannot be changed. The value type should be considered independent.

    Reference Type: The address doesn't change, but the value it points to changes. Any change in the value of a member of the class will overwrite the original value.

    The reference type is considered to be always overridden by the last value.

    As long as you add ref or out in front of the type, it will become a reference type.

  3. Anonymous users2024-02-03

    The memory is full of 010101....

    It's just that there is a partition, and all we can use is the area allocated to the program, and a lot of the memory reserved by the system is not allowed for you to access.

    For a program, what we need to know is the heap and the stack.

    A stack is a place where you can put a fixed type, and you can determine the existence and size of it at compile time, all in this place.

    For example, if you define an int variable i in the program, then this i is placed in the stack (whether it is the content of i or i itself).

    For objects generated at any time during operation, they are in the heap, which is not formatted, or can be placed in anything.

    The reason why the various data types are divided is to facilitate inspection and improve operational efficiency.

    For example, if the int type is 4 bytes, then there must be nothing wrong with finding 4 bytes of memory at runtime, otherwise some mechanism is needed to indicate how many bytes this type occupies, and then you can find this data accordingly.

    Another example is int[10], this array, what to do if we want to find the 5th number, we only need to know the starting memory position of this array, and then offset the position of 5x4=20 addresses to directly find the 5th number.

    Those who have learned C, or the compilation principle, have a deeper understanding of this, and I don't know the specific details very well, and the above is just my personal understanding.

  4. Anonymous users2024-02-02

    c Yes. .NET framework, so it can only be developed in. .NET framework.

    Since the assigned objects are all in. Unified management under the .NET framework, the reference to C allocation generally does not need to be defined to delete **** memory, although it can be understood as the same concept as the pointer of C++, but it actually points to only a certain block inside the operating system that can be used in memory.

    C++ runs under the operating system, and the address it is assigned to is usually the address of the heap in the program. However, you can modify the pointer value to point it to a different internal address of the operating system. Since C++ obtains the memory address of the operating system, the pointer needs to be released when it is not in use.

  5. Anonymous users2024-02-01

    The definition of reference type in c looks like this:

    …The basic difference between value types and reference types is how they are stored in memory. ......The address of the reference type variable is stored on the stack, but the actual object is stored on the heap. ......

    The definition of a reference type implies that a reference type in C is equivalent to a pointer to C++, but the C language itself has done some work to tie the pointer to the object it points to.

    Reference typePassing a copy by reference is a reference, not actually the address of memory.

    Reference typePassing a copy by reference is a reference, not actually the address of memory.

    Reference typePassing a copy by reference is a reference, not actually the address of memory.

    In the case of Unsafe, we can declare a pointer of the value type like in C++! But for reference types, this is not true. I think that in C, the objects of the reference type are all managed by the system, and if we are allowed to point to them with pointers, the whole program will have to be messed up!!

  6. Anonymous users2024-01-31

    c Cross-platform is poor. For operations on memory. In order to make C more acceptable, Microsoft omitted it as much as possible when it integrated, in fact, simplifying the language with fewer memory operations is also the advantage of C.

    C++ is a hybrid language of OOP and general-purpose programming. More complex, more efficient, but more cumbersome.

Related questions
25 answers2024-02-08

Relying on strength, hard work, character, character, and good looks, he has a unique voice condition, but he is keen to do what he wants, instead of singing some songs that the public likes with the crowd, he dances smoothly, moves neatly, and is a natural stage king! His athletic talent is obvious. He does public welfare and leads Lu Fan to do public welfare together. >>>More

12 answers2024-02-08

Listed companies distribute dividends to shareholders, that is, when the company's earnings are converted into capital increases, or when allotments are carried out, the stock price must be ex-righteous. When a listed company distributes its surplus to shareholders in cash, the stock price goes ex-dividend. To put it simply: >>>More

21 answers2024-02-08

As far as I know, there are 2, one is Dr. Lizard, a Spider-Man similar to the Black Spider in "Spider-Man 3".

9 answers2024-02-08

Don't say that girls are not suitable, if it is only used for commuting or shopping, it will be uncomfortable for boys to ride. Because road bikes are primarily designed for speed, they are narrower and have thin tires that can feel bumpy and difficult to balance. In order to improve the explosive power of the cyclist's legs, it is convenient to straighten the legs when riding, the saddle of this bicycle design is very high, and the saddle design is generally very narrow and hard, not only the comfort is very poor, but also the friction of the lower part is very strong, you see that the general road bike is almost always standing riding. >>>More

9 answers2024-02-08

She rarely talks to boys, which shows that she is a more introverted girl, and introverts have strong psychological defenses, and they will not easily reveal their inner thoughts and thoughts. >>>More