草庐IT

memory-address

全部标签

【异常】前端提示FATAL ERROR: Committing semi space failed. Allocation failed - JavaScript heap out of memory

一、报错内容---LastfewGCs--->[13880:00000215307018C0]2089668ms:Scavenge636.6(662.2)->635.7(662.2)MB,1.8/0.0ms(averagemu=0.997,currentmu=

C++ 继承 : does lack of virtual destructor lead to memory leak?

这个问题在这里已经有了答案:Possiblememoryleakwithoutavirtualdestructor?(3个答案)关闭6年前。我对自己经常问自己的一个问题有疑问,是这样的情况:两个类,没有虚析构函数classBase{intmyInt;};classDerived:publicBase{intmyIntDerived;};intmain(){Base*base=newDerived;Derived*derived=newDerived;deletebase;deletederived;}第一个delete导致内存泄漏而第二个delete没问题,这样说对吗?

C++ 多态性 : Is there any way to find the address of an object's member function?

如果我有一个纯虚拟基类及其多个派生...classBase{public:virtualvoidmethod1()=0;}classDerived1:publicBase{public:voidmethod1()override{...}}classDerived2:publicBase{public:voidmethod1()override{...}}有什么方法可以让持有未知派生类型对象的Base*的代码确定它持有的对象的method1()函数的地址Base*指针指向?我想做的是这样的:voidsomeOtherFunction(Base*pb){printf("IfIcallpb

c++ - "Misaligned address error"是什么意思?

首先-抱歉具体细节。我通常会尝试将我的SO问题归结为仅包含相关内容的通用“A类”内容,但我不确定这里问题的根源是什么。我有一个矩阵类模板,看起来像这样(只显示我认为相关的部分):templateclassMatrix{private://constintrows,cols;std::array,R>m;public:inlinestd::array&operator[](constinti){returnm[i];}conststd::arrayoperator[](constinti)const{returnm[i];}templateMatrixoperator*(constMat

c++ - 隐式转换产生 "error: taking address of temporary"(GCC vs clang)

在试验强类型整数时,我遇到了一个来自GCC8.2的奇怪错误:error:takingaddressoftemporary我可以想象上述错误有意义的典型场景,但在我的情况下我没有遇到问题。重现错误的缩小(人为)示例如下:#include#includeenumclassEnum:std::size_t{};structPod{std::size_tval;constexproperatorEnum()const{returnstatic_cast(val);}};templateconstexprvoidfoo(){usingFoo=std::integral_constant;//[G

c++ - 为什么 Visual C++ 2010 提示 'Using uninitialized memory' ?

我有一个函数,它接受一个指向缓冲区的指针,以及该缓冲区的大小(通过指针)。如果缓冲区不够大,它会返回一个错误值并在输出参数中设置所需的长度://FillBufferisdefinedinanothercompilationunit(OBJfile).//Wholeprogramoptimizationisoff.intFillBuffer(__int_bcount_opt(*pcb)char*buffer,size_t*pcb);我这样调用它:size_tcb=12;char*p=(char*)malloc(cb);if(!p)returnENOMEM;intresult;for(;;

c++ - boost iostream : how to turn ifstream into memory mapped file?

我想要的是简单地打开文件作为内存映射文件进行读取-以便将来以更快的速度访问它(例如:我们打开文件读取它结束,等待并一次又一次地读取它)同时我希望该文件可以被其他程序修改,当他们修改它时,我希望我的ifstream也能修改。如何使用boostiostreams(或boostinterprocess)做这样的事情?我们可以只是tallos-嘿,这个文件应该为所有应用程序进行内存映射?所以我尝试这样的代码:#include#include#includeusingnamespaceboost::iostreams;intmain(intargc,char**argv){streamout;t

c++ - 简单代码导致错误读取变量: Cannot access memory at address

我正在尝试使用支持python的gdbMinGW-builds.我遇到了一个错误。这是一个相当简单的代码,在MSVC下调试时它工作正常。D:\CppProject\c1\bin\Debug>gdbc1.exeGNUgdb(GDB)7.6(copyright,license,bugreport,etcomittedhere)ReadingsymbolsfromD:\CppProject\c1\bin\Debug\c1.exe...done.(gdb)l1#include2#include34usingnamespacestd;56intmain()7{8vectorv;9v.push_b

c++ - 函数地址和函数地址的地址之间没有区别吗?

这个问题在这里已经有了答案:Whydofunctionpointerdefinitionsworkwithanynumberofampersands'&'orasterisks'*'?(5个答案)Howdoesdereferencingofafunctionpointerhappen?(5个答案)关闭9年前。voidf(){}voidtest(){autofn_1=f;autofn_2=&f;assert(fn_1==fn_2);//OKfn_1();//OKfn_2();//OK(*fn_1)();//OK(*fn_2)();//OK(**fn_1)();//OK(**fn_2)()

c++ - 临时/"non-addressable"固定大小数组?

标题没有更好的名字,我不确定我是否能够足够清楚地解释自己。我正在寻找一种通过索引访问“数据类型”的方法,但不强制编译器将其保存在数组中。问题发生在编写基于SSE/AVX内在函数的低级代码时。为了便于编程,我想编写如下代码,在“寄存器”(数据类型__m512)上使用固定长度循环:inlinevoidload(__m512*vector,constfloat*in){for(inti=0;ivector1和vector2被定义为数组的事实对编译器来说似乎很麻烦(在我的例子中是icc):看起来被迫使其“可寻址”,将其保存在堆栈中,从而生成大量我不需要的load和store指令。据我所知,这是