The release of object memory for class C

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

    I don't know if you know anything about memory allocation.

    Depending on how your object is instanced, if the direct instance is allocated on the stack without new memory, then you don't need to worry about the space that the class occupies will have its own memory at the end of the object's lifecycle.

    If it's new, then the memory is allocated on the heap, and if you don't delete the class with delete, then the memory will be leaked.

    If you say, It's not new, point out with a pointer, and then release, I don't know if that's the case.

    class a{};

    a newa_one;

    a* newptr;

    newptr = &newa_one;

    It's okay to point to this pointer, but you can't use delete to release it, because the object address is on the stack, and the object lifecycle is in the area where the object is used.

  2. Anonymous users2024-02-04

    If your class object is new, you can delete.

    Whether or not you can "release directly" depends on how your program is written.

    Only new can be deleted, and only malloc can be free

  3. Anonymous users2024-02-03

    Didn't understand what to ask.

    Normal to be. 1. Delete database data.

    2. Delete class objects.

    The method of operating the two together has this function in the SDK.

  4. Anonymous users2024-02-02

    1. This paragraph ** is wrong and crashes after running.

    void check_leak(double *p, int num);

    check_leak(q,5);

    This pointer is passed by value, and in fact the p inside the check leak function does not affect the q outside. So the program creates a new array, and then destroys a memory ...... that I don't know **

    2. It is feasible to apply for memory in a function and release it outside the function. Because the applied memory is on the heap, it is valid throughout the program.

    However, it is not recommended. Applying releases should appear in pairs in the same scope, otherwise it's easy to carelessly forget delete.

  5. Anonymous users2024-02-01

    Yes, just control it and don't release it repeatedly.

  6. Anonymous users2024-01-31

    If you apply for it yourself, you need to release the memory. If you're just a local variable, like an int defined like this

    arr[10000][10000], it does not need to be released. The system will release it automatically.

Related questions
6 answers2024-02-09

Many classes are derived a lot and take up a lot of resources. >>>More

11 answers2024-02-09

It's not interesting, it's just that there's these members and methods in this category.

36 answers2024-02-09

You are willing to wait for her, proving that you love her very much. Personally, I think you should tell her directly: there is someone waiting for you where you are. >>>More

18 answers2024-02-09

I just wanted to play my world.,I also found this problem.,But it's all trivial.,Open my file.,Then search the office to find the mclauncherup dater file.,He's like an update system.,Open it My world will be automatically updated.,It'll be fine in a while.,Although it's a little late.,I hope I can help.。

25 answers2024-02-09

What English? Can you elaborate? It should be the volume label of your C disk,That doesn't matter,You can delete it from "My Computer" Click on the C disk,The method is to click on the C disk symbol,The cursor flashes to delete the modified content,That drive letter is a symbol,You can also write it as"System disk"For example, you can write it as Windows XP to remind you that the C disk is a system disk when you operate on the disk,There is no other use。 >>>More