- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
下面的代码显示了 valgrind 中的一个小的 48 字节泄漏。
#include <X11/Xlib.h>
#include <GL/glx.h>
#include <unistd.h>
int main( int argc, char* argv[] )
{
Display* _display;
Window _windowHandle;
XVisualInfo* _visual;
GLXContext _context;
Atom _deleteWindowMessage;
Atom _pingWindowMessage;
_display = XOpenDisplay( NULL );
int attributes[] = { GLX_RGBA,
GLX_DOUBLEBUFFER,
GLX_RED_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_GREEN_SIZE, 8,
GLX_ALPHA_SIZE, 8,
GLX_DEPTH_SIZE, 8,
GLX_STENCIL_SIZE, 0,
0 };
_visual = glXChooseVisual( _display,
DefaultScreen( _display ),
attributes );
_context = glXCreateContext( _display,
_visual,
0,
GL_TRUE );
Colormap colormap;
colormap = XCreateColormap( _display,
RootWindow( _display, _visual->screen ),
_visual->visual,
AllocNone );
XSetWindowAttributes windowAttributes;
windowAttributes.colormap = colormap;
windowAttributes.border_pixel = 0;
windowAttributes.event_mask = ExposureMask | StructureNotifyMask;
_windowHandle =
XCreateWindow( _display,
RootWindow( _display, _visual->screen ),
0,
0,
1280,
720,
0, // Borderwidth
_visual->depth, // Depth
InputOutput,
_visual->visual,
CWBorderPixel | CWColormap | CWEventMask,
&windowAttributes );
XFreeColormap( _display, colormap );
XMapWindow( _display, _windowHandle );
// causes 48 byte leak...
glXMakeCurrent( _display,
_windowHandle,
_context );
sleep( 3 );
XUnmapWindow( _display, _windowHandle );
XDestroyWindow( _display, _windowHandle );
glXMakeCurrent( _display,
None,
NULL );
glXDestroyContext( _display, _context );
XFree( _visual );
XCloseDisplay( _display );
return 0;
}
这段代码所做的只是为 GLX 渲染初始化一个窗口,然后将其拆除。有趣的是,当我调用 glXMakeCurrent() 时,我泄漏了 48 个字节...... valgrind 输出如下所示:
[developer@localhost ~]$ valgrind --tool=memcheck --leak-check=full ./simplex
==9531== Memcheck, a memory error detector
==9531== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==9531== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info
==9531== Command: ./simplex
==9531==
==9531==
==9531== HEAP SUMMARY:
==9531== in use at exit: 248 bytes in 6 blocks
==9531== total heap usage: 1,265 allocs, 1,259 frees, 2,581,764 bytes allocated
==9531==
==9531== 48 bytes in 1 blocks are definitely lost in loss record 5 of 6
==9531== at 0x400591C: malloc (vg_replace_malloc.c:195)
==9531== by 0x349D0F8: ??? (in /usr/lib/nvidia/libGL.so.180.60)
==9531==
==9531== LEAK SUMMARY:
==9531== definitely lost: 48 bytes in 1 blocks
==9531== indirectly lost: 0 bytes in 0 blocks
==9531== possibly lost: 0 bytes in 0 blocks
==9531== still reachable: 200 bytes in 5 blocks
==9531== suppressed: 0 bytes in 0 blocks
==9531== Reachable blocks (those to which a pointer was found) are not shown.
==9531== To see them, rerun with: --leak-check=full --show-reachable=yes
==9531==
==9531== For counts of detected and suppressed errors, rerun with: -v
==9531== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 30 from 8)
如果你在 sleep 之前注释掉对 glXMakeCurrent() 的调用,泄漏就会消失......当然,我需要进行该调用才能渲染任何东西!
真正的问题是我的应用程序创建了许多子窗口,每个子窗口都关联了 GLX 上下文......并且每个都泄漏了相同的 48 字节......我不知道还能尝试什么(代码正在清理 GLX上下文)...有什么想法吗?
最佳答案
好的,看来真的没有漏水
Valgrind 仍在报告泄漏,但我编写了一个测试应用程序,它在随机位置显示了数千个窗口,并且内存通过顶部完全平坦...所以,看起来我需要一个用于 glx 应用程序的抑制文件.
关于c - 为什么我的简单 GLX 应用程序会泄漏内存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1735344/
这似乎是一个 X2go 服务器问题,如此处所述 http://wiki.x2go.org/doku.php/doc:de-compat 报价 Therefore, there are 4 reason
官方 XCB 文档告诉我们 using OpenGL purely with XCB is impossible : 还必须使用 Xlib。 This post作者 Bart Massey(XCB 的
我当前正在将开源OpenGL游戏移植到OpenGL ES。目标设备运行Linux,并且具有相对较弱的CPU(ARM11系列,带有FPU)。它具有OpenGL ES加速器,但没有OpenGL加速器。 最
我想知道是否可以通过任何文件描述符和 [select |投票 | epoll]它。 通常,如果我是对的,glXSwapBuffers() 不会阻止进程,所以我可以做类似的事情: int init()
我正在尝试从 GLX 上下文中读取像素。这是我创建上下文的方式 int Attributes[] = { GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, GLX_REND
我用 python 编写了一个 opengl 程序,但遇到了 glxChooseVisual 的问题。 基本上,如果我使用下面的属性,一切都很好,则无法找到匹配的视觉效果 self.add_a
我尝试使用 gl 3.3 上下文创建窗口,但当我尝试调整它的大小时,它正在消耗 cpu 并出现滞后。 My Code : #include #include #include #include
当后台缓冲区和前台缓冲区之间交换时,后台缓冲区中的内容变得不确定。我想使用“窗口系统”来定义它,例如 GLX、EGL、WGL。使用“原生”渲染器,如 OpenGL (glClear) 是我的备份计划,
我正在尝试使用 glX 函数 (glXSwapIntervalMESA()),但编译器返回 undefined reference 错误。 我已经尝试与 X11 和 Xext 以及 glx 进行链接,
系统规范和任务 我在 Ubuntu 10.10 上使用 Code::Blocks 并使用 OpenGL 和 glx。我正在学习 C++(从 C 和 Java 的背景),所以任何代码的风格都不符合任何真
下面的代码显示了 valgrind 中的一个小的 48 字节泄漏。 #include #include #include int main( int argc, char* argv[] ) {
正在尝试设置用于图像处理的桌面站。我最近安装了 ubuntu 16.04 并经历了 guide由 Adrian 安装 python3、cv2 和虚拟环境。 我没有使用 cv2 3.1.0,而是使用了
我正在努力使用 pygame 初始化 OpenGL 显示。和pyopengl . import pygame pygame.init() pygame.display.set_mode((1920,
我在 Ubuntu 10.04 中安装了 OpenGL 和 freeglut,它在 10.04 和 10.10 中运行良好。但是在我升级到11.04之后,我用OpenGL开发的应用程序不能正常运行。它
我正在做一个驱动模拟项目。我在 VS2010 IDE 上使用 opengl。 对象 'car_param'(不重要)有一个 vector glm::vec3 'dir',我想使用 glm\glx 旋转
我正在尝试创建一个 Linux 应用程序 - 在这种情况下是一个屏幕保护程序 - 事实证明,非常很难找到有关使窗口全屏的简单任务的信息。甚至现有屏幕保护程序的代码也没有提及它们是如何管理它的,而且我还
我正在使用 xcb 在 X11 下学习 OpenGL,我很难弄清楚视觉效果和 fbconfigs(您在 glxinfo 中找到的)之间的区别 据我所知,视觉是一组与深度缓冲区、模板缓冲区、帧缓冲区等相
Covid 让我远程工作,而我被困在这里。 我对 UI 使用 X11 转发没有问题,甚至对 3D OpenSceneGraph 可视化也没有问题,但是我需要运行的新应用程序在远程计算机上出现以下错误:
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许在 Stack Overflow 上提出有关通用计算硬件和软件的问题。您可以编辑问题,使其成为
问题:如何获取 GLXContext 并将其传递给 clCreateContextFromType? 信息: 我正在学习 openGL CL 互操作的工作原理。我已经成功地学习了 openCL 的工作
我是一名优秀的程序员,十分优秀!