Analysis of memory problems that determine the C ++ programming speed

Source: Internet
Author: User

The results of C ++ development on a computer with high speed and large memory are significantly different from those on a computer with an old memory error. Memory Errors are kept within the control range, memory Errors have a very large impact on C and C ++ programming.

Memory Errors in C and C ++ programs are extremely harmful: they are common and may cause serious consequences. Many of the most serious security announcements from the Computer Emergency Response Team (see references) and vendors are caused by simple memory errors. Since the end of 1970s.

C programmers have been discussing such errors, but their impact was still very high in 2007. Even worse, many C and C ++ programmers may think that memory errors are uncontrollable and mysterious, and they can only be corrected, cannot be prevented.

The importance of correct Memory Management

C and C ++ programs with memory errors may cause various problems. If they leak memory, the running speed will gradually slow down and the operation will eventually stop. If the memory is overwritten, the Operation will become very fragile and vulnerable to attacks by malicious users.

In 1988, the famous Morris worm attacked the latest security alerts related to Flash Player and other key retail programs, all related to buffer overflow: "Most computer security vulnerabilities are buffer overflow ", rosydney Bates wrote in 2004.

Many other general languages (such as Java? Ruby, Haskell, C #, Perl, Smalltalk, etc.), each language has many enthusiasts and their respective advantages. However, from the computing point of view.

The main advantages of each programming language over C or C ++ programming are closely related to ease of memory management. Memory-related programming is so important, and correct application in practice is so difficult, so that it controls all other variables or theories of object-oriented programming languages, functional programming languages, advanced programming languages, declarative programming languages, and other programming languages.

Like a few common errors of other types, memory errors are a hidden hazard: they are hard to reproduce and the symptoms are usually not found in the source code. For example, whenever and wherever a memory leak occurs, it may be totally unacceptable to the application, and the memory leak is not obvious.

  • How to better develop C ++ Builder
  • Is C ++ really poorly compatible?
  • Study on VC ++ Development Platform
  • Analysis on the complexity of C ++
  • Is C ++ just a language for objects?

Therefore, for all these reasons, we need to pay special attention to the memory problems of C and C ++ programming. Let's take a look at how to solve these problems. Let's not talk about the language.

Memory Error category

First, do not lose confidence. There are many ways to deal with memory problems. First, we will list all possible problems:

1. Memory leakage

2. misallocation, including a large increase in free () memory and uninitialized references

3. Floating pointer

4. array boundary Violation

This is all types. Even if you migrate data to a C ++ object-oriented language, these types will not change significantly; whether the data is a simple type or a C-language struct or C ++ class, the memory management and reference models in C and C ++ are the same in principle. The majority of the following content is the "pure C" language, which is mainly used for exercises to extend to C ++ programming.

This simplifies the use of objects. All internal mechanisms that users do not need to know are hidden behind the scenes. All of this is included in the concept of object-oriented programming. OOP can be programmed in a modular way to avoid starting from scratch each time. The C ++ Builder program is oriented to OOP.

Because C ++ Builder uses a large number of components. After a component is generated, you can use it again in any C ++ Builder program. The components can also be expanded to generate new components with new functions through inheritance. The best thing is that the component hides all content details, allowing programmers to focus on making full use of the component.

  1. Introduction to C ++
  2. Summary Notes on learning and exploring C ++ library functions
  3. Basic Conception and method of C ++ Class Library Design
  4. Does C ++ really have market value?
  5. Basic Conception and method of C ++ Class Library Design

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.