Selecting and displaying a large number of lines consumes a lot of memory and crashes

I am using OpenCascade V7.4.0 on 32bit windows.

I am making a process to select the line drawn on the screen and highlight the selected line.
view and context are created from the parent viewer respectively.

context-> Select (xMin, yMin, xMax, yMax, view, Standard_False);
view-> Redraw ();


view = viewer-> CreateView ();
context = new AIS_InteractiveContext (viewer);


The context can have lines that can reach up to thousands to tens of thousands,
The more lines you select and display, the more memory you use than you expected.
Eventually the app will crash when the memory usage exceeds 1GB.
Also, memory usage will increase significantly when Redraw () is performed.

How to select and display a large number of lines but the app does not crash,
Or is there a good way to reduce memory usage?

Best regards.


Kirill Gavrilov's picture

On which system do you observe such results? Which GPU is used (Intel / AMD / NVIDIA)?

Keito Okajima's picture

The system I am currently using for development is as follows.

OS: Microsoft Windows 10 64bit
CPU: Intel (R) Core (TM) i7-8565U
GPU: Intel (R) UHD Graphics 620 (Integrated GPU)
Memory: 16GB

The final application will also be used on other computers. (windows 32bit/64bit)
In that case, it seems that Intel's Integrated  GPU is mainly used.

Kirill Gavrilov's picture

I've seen unexpectedly high memory usage on such configurations with Intel GPUs.
Apparently, Intel's OpenGL driver does very bad job regarding memory management compared to other vendors (NVIDIA, AMD - checking your application on such systems should help in analysys).
As result, small VBO objects require enormously large memory blocks (much larger than necessary to fit VBO data), and the same scene fits into 32-bit memory space without issues on NVIDIA/AMD drivers, but may go even out of memory on Intel drivers.

You may consider reporting such issue to Intel (maybe they haven't yet received such feedback from their users and unaware or issue?) or workaround it on application side.
So far, the only workaround is to avoid creation of large number of small objects - try packing small objects into larger ones.
Of course, using 64-bit builds would avoid out of memory issue as well (though memory consumption will be high) - which is what Intel driver probably expects nowadays (don't know when exactly issue with Intel driver appeared).

Keito Okajima's picture

Thank you for the quick response.
First of all, I would like to consider implementing a workaround on the application side to prevent this phenomenon.