草庐IT

gpu-constant-memory

全部标签

c++ - 为什么我在检查核心转储时进入 gdb "Cannot access memory at address 0x..."?

我在分析核心转储时尝试打印以下行时收到此消息。(gdb)p/x*($esi)Cannotaccessmemoryataddress0xe6d3a030我提到%esi(0xe6d3a030)指向的地址应该指向一些有效的分配数据。(当我自己运行这个程序并按照相同的指令中断时,这个打印有一些有意义的信息)造成这种情况的可能原因是什么?我是否遗漏了核心转储中的一些信息?如果是,我缺少什么信息?核心转储不应该包含所有已分配内存的快照吗?编辑:当我在加载核心转储时在gdb“维护信息部分”命令中使用时,我得到下面显示的信息。我可以看到地址0xe6d3a030在0xe6d00000->0xe6dfb0

c++ - C++11 之前的 "Constant expressions"

constexpr关键字是在C++11中引入的,因为(我认为)是“常量表达式”的相应概念。然而,这个概念隐含在C++98/c++03中,因为数组声明需要一个常量表达式://valid:inta[sizeof(int)];intb[3+7];intc[13/4];constintn=3;intd[n];//invalid:intm=4;inte[m];还有其他“常量表达式”,即可以(和/或必须)在编译时计算的表达式;一个例子是模板参数。对于C++11之前的版本,C++98/03标准或其他地方是否存在以下内容?需要常量表达式的语法结构的完整列表(例如数组声明和模板实例化)管理此类常量表达式

c++ - "std::bad_alloc": am I using too much memory?

消息:terminatecalledafterthrowinganinstanceof'std::bad_alloc'what():std::bad_alloc我查看了gdb回溯,这是我自己实现的最低级别的方法:/**getanarrayofvec3s,whichwillbeusedforrenderingtheimage*/vec3*MarchingCubes::getVertexNormalArray(){//UsedthesamearraysizetechniqueasgetVertexArray:wewantindicestomatchupvec3*array=newvec3[

c++ - "live C++ objects that live in memory mapped files"?

因此,我在Gamasutra阅读了JohnCarmack的采访,其中他谈到了他所谓的“存在于内存映射文件中的实时C++对象”。以下是一些引用:JC:Yeah.AndIactuallygetmultiplebenefitsoutofitinthat...ThelastiOSRageproject,weshippedwithsomenewtechnologythat'susingsomecleverstufftomakeliveC++objectsthatliveinmemorymappedfiles,backedbytheflashfilesystemonhere,whichishowI

c++ - C/C++ : Optimization of pointers to string constants

看看这段代码:#includeusingnamespacestd;intmain(){constchar*str0="Watchmen";constchar*str1="Watchmen";char*str2="Watchmen";char*str3="Watchmen";cerr(const_cast(str0))(const_cast(str1))(str2)(str3)产生这样的输出:0x4430000x4430000x4430000x443000这是在Cygwin下运行的g++编译器上。即使没有开启优化,指针也都指向同一个位置(-O0)。编译器是否总是优化得如此之多,以至于它会

c++ - std::is_constant_evaluate 行为

GCC9已经实现了std::is_constant_evaluated。我用它玩了一点,我意识到它有点棘手。这是我的测试:constexprintFn1(){ifconstexpr(std::is_constant_evaluated())return0;elsereturn1;}constexprintFn2(){if(std::is_constant_evaluated())return0;elsereturn1;}intmain(){constexprinttest1=Fn1();//Evaluatesto0inttest2=Fn1();//Evaluatesto0intcons

c++ - 警告 : overflow in implicit constant conversion

在下面的程序中,第5行确实按预期给出了溢出警告,但令人惊讶的是,第4行在GCC中没有给出任何警告:http://www.ideone.com/U0BXnintmain(){inti=256;charc1=i;//line4charc2=256;//line5return0;}我在想这两行都应该给出overflow警告。还是我缺少什么?我做这个实验的主题是:typedeftypechecking?在那里我说了以下内容(我从答案中删除了,因为当我运行它时,它并没有像我预期的那样显示)://However,you'llgetwarningforthiscase:typedefintT1;ty

c++ - Python ctypes : how to free memory? 获取无效指针错误

我想从带有ctypes的C/C++库中获取一些字符串到python中。我的代码如下所示:lib中的代码:constchar*get(structsomething*x){[...]//bufisastringstreamreturnstrdup(buf.str().c_str());}voidfreeme(char*ptr){free(ptr);}Python代码:fillprototype(lib.get,c_char_p,POINTER(some_model)])fillprototype(lib.freeme,None,[c_char_p])//whatiwanttodohere

c++ - `memory_resource` 的用途和用途是什么?

标准C++17包含一个新的命名空间pmr,其中包括一组以memory_resource的名称分组的类。在网上搜了一下,发现很少有关于它的低俗信息,直接结果就是这个问题:pmr,尤其是pmr::memory_resource背后的主要思想是什么?把问题详细一点,我脑子里的一些问号是:它带来了什么新的东西,或者它解决了哪些限制?与allocator有什么区别?多态是否意味着可以选择运行时提供给容器构造函数的allocator?(例如用于测试目的)它对实现内存池或其他内存管理方案有帮助吗?上下文:为了创建memorypool分配器,我找到了有关此命名空间的信息。阅读像pool_options

c++ - 警告 : deprecated conversion from string constant to 'char*' '

这个问题在这里已经有了答案:关闭11年前。PossibleDuplicate:Howtogetridofdeprecatedconversionfromstringconstantto‘char*’warningsinGCC?我使用库中的以下函数,但我无法更改:HRESULTDynamicTag(char*pDesc,int*constpTag);我使用它如下。我已经创建了实现上述功能的库提供的类的对象。inttag=0;g_pCallback->DynamicTag("MyLogger",&tag);我收到以下警告:warning:deprecatedconversionfromst