C program with minimum RAM

后端 未结 6 1544
离开以前
离开以前 2021-02-08 15:33

I want to understand the memory management in C and C++ programming for Application Development. Application will run on the PC.

If I want to make a program which uses R

6条回答
  •  不知归路
    2021-02-08 16:15

    This is difficult because on your PC, the program will be running out of RAM unless you can somehow execute it out a ROM or Flash.

    Here are the points to consider:

    Reduce your code size.
    Code takes up RAM.

    Reduce variable quantity and size.
    Variables need to live somewhere and that somewhere is in RAM.

    Reduce character literals.
    They too, take up space.

    Reduce function call nesting.
    A function may require parameters, which are placed in RAM. A function that calls other functions needs a return path; the path is stored in RAM.

    Use RAM from other devices.
    Other devices, such as the Graphics Processor and your harddrive adaptor card, may have RAM you can use. If you use this RAM, you're not using the primary RAM.

    Page memory to external device.
    The OS is capable of virtual memory and can page memory out to an external device, such as a hard drive.

    Edit 1 - Dynamic libraries Too reduce the RAM footprint of your program, you could allocate a an area where you swap out library functions. This is similar to the DLL concept. When a function is needed, you load it from the hard drive into the reserved area.

提交回复
热议问题