When can a memory leak occur?

前端 未结 8 2118
野性不改
野性不改 2021-02-08 06:52

I don\'t know what to think here...

We have a component that runs as a service. It runs perfectly well on my local machine, but on some other machine (on both machine RA

8条回答
  •  时光取名叫无心
    2021-02-08 07:35

    Just a hunch,

    But I have had trouble in the past when allocating arrays as so

    int array1[SIZE];  // SIZE limited by COMPILER to the size of the stack frame
    

    when SIZE is a large number.

    The solution was to allocate with the new operator

    int* array2 = new int[SIZE];  // SIZE limited only by OS/Hardware
    

    I found this very confusing, the reason turned out to be the stack frame as discussed here in the solution by Martin York: Is there a max array length limit in C++?

    All the best,

    Tom

提交回复
热议问题