小编Gab*_*el 的帖子

C++ 程序因 std::bad_alloc 而终止,但 valgrind 报告没有内存泄漏

我的程序失败并显示“std::bad_alloc”错误消息。该程序是可扩展的,因此我使用 valgrind 在较小的版本上进行了测试,并且没有内存泄漏。

这是统计力学的应用,所以我基本上制作了数百个对象,更改它们的内部数据(在本例中为双精度的 stl 向量),并写入数据文件。对象的创建位于循环内,因此当循环结束时,内存将被释放。就像是:

for (cont=0;cont<MAX;cont++){
         classSection seccion;
         seccion.GenerateObjects(...);
         while(somecondition){
                seccion.evolve();
                seccion.writedatatofile();
         }}
Run Code Online (Sandbox Code Playgroud)

因此有两个变量决定程序的计算时间、系统的大小和运行次数。只有运行多次的大型系统才会崩溃。关于如何解决这个内存问题有什么想法吗?

谢谢,

c++ memory valgrind

5
推荐指数
1
解决办法
2049
查看次数

在fortran代码的gprof输出上_IO_wfile是什么?

我有一些使用intel fortran编译器ifort编译的fortran代码.当我使用gprof进行配置文件测试时,我得到的大部分时间用于IO操作,我想找到文件的结尾,但我找不到更多关于此的文档:

index % time    self  children    called     name
                                                 <spontaneous>
[1]     20.6    0.07    0.00                 _IO_wfile_seekoff [1]
-----------------------------------------------
                                                 <spontaneous>
[2]     20.6    0.07    0.00                 sforcepf_ [2]
-----------------------------------------------
                                                 <spontaneous>
[3]     20.6    0.02    0.05                 _IO_wfile_underflow [3]
                0.01    0.04  258716/258717      strncmp [4]
-----------------------------------------------
                0.00    0.00       1/258717      _IO_wdefault_doallocate [15]
                0.01    0.04  258716/258717      _IO_wfile_underflow [3]
[4]     14.7    0.01    0.04  258717         strncmp [4]
                0.04    0.00 3104592/3109256     strerror_r [5]
-----------------------------------------------
                0.00    0.00    4664/3109256     __strcmp_sse42 [14]
                0.04    0.00 3104592/3109256     strncmp [4]
[5]     11.8    0.04    0.00 3109256         strerror_r [5]
-----------------------------------------------
Run Code Online (Sandbox Code Playgroud)

那么,问题是,这个IO是针对Linux,还是针对ifort,还是针对fortran?我正在尝试优化此代码,并且在google中找不到有关此条款的有用信息.

fortran gprof intel-fortran

4
推荐指数
1
解决办法
511
查看次数

标签 统计

c++ ×1

fortran ×1

gprof ×1

intel-fortran ×1

memory ×1

valgrind ×1