Archived issue #0028657
Foundation Classes - OSD_Thread does not release thread resources on non-Windows platforms
Description
OSD_Thread destructor does nothing on Linux:
and so does ::Run() as well.
If application does not call explicitly OSD_Thread::Detach() or OSD_Thread::Wait() - it ends up with leaked resources since when thread finishes it's job, nobody will free memory.
void OSD_Thread::Destroy ()
{
#ifdef _WIN32
// On Windows, close current handle
if ( myThread )
CloseHandle ( myThread );
#else
// On Unix/Linux, do nothing
#endif
myThread = 0;
myThreadId = 0;
}
and so does ::Run() as well.
If application does not call explicitly OSD_Thread::Detach() or OSD_Thread::Wait() - it ends up with leaked resources since when thread finishes it's job, nobody will free memory.
Steps to reproduce
Not required.
Results Ubuntu 17.04:
Results Android 4.4.2:
Results Android 6.0.1:
static Standard_Address OCC28657_ThreadFunc (Standard_Address )
{
return 0;
}
static Standard_Integer OCC28657 (Draw_Interpretor& , Standard_Integer , const char** )
{
OSD_Thread aThread (OCC28657_ThreadFunc);
for (Standard_Integer anIter = 0; anIter < 10000; ++anIter, ++aDumpIter)
{
aThread.Run();
}
return 0;
}
//
meminfo
OCC28657
meminfo
Results Ubuntu 17.04:
Private memory: 49 MiB Working Set: 83 MiB (peak: 83 MiB) Virtual memory: 356 MiB Heap memory: 4 MiB ... Private memory: 80021 MiB Working Set: 163 MiB (peak: 163 MiB) Virtual memory: 80367 MiB Heap memory: 8 MiB
Results Android 4.4.2:
Private memory: 16 MiB Working Set: 67 MiB (peak: 67 MiB) Virtual memory: 520 MiB Heap memory: 2 MiB ... Private memory: 26 MiB Working Set: 77 MiB (peak: 77 MiB) Virtual memory: 532 MiB Heap memory: 10 MiB
Results Android 6.0.1:
Private memory: 139 MiB Working Set: 41 MiB (peak: 41 MiB) Virtual memory: 1577 MiB Heap memory: 7 MiB ... 1000 Private memory: 1142 MiB Working Set: 65 MiB (peak: 65 MiB) Virtual memory: 2618 MiB Heap memory: 9 MiB ... ... W/libc: pthread_create failed: couldn't allocate 1044480-bytes mapped space: Out of memory ... W/libc: pthread_create failed: couldn't allocate 1044480-bytes mapped space: Out of memory Private memory: 1576 MiB Working Set: 66 MiB (peak: 66 MiB) Virtual memory: 3053 MiB Heap memory: 9 MiB
Public activity
14 archived notes
Participants are labeled by their role within this record.
Branch [archived branch] has been created by Author.
[revision removed]
Detailed log of new commits:
Author: Author
Date: Sat Apr 15 18:57:30 2017 +0300
0028657: Foundation Classes - OSD_Thread does not release thread resources on non-Windows platforms
~OSD_Thread(), OSD_Thread::SetFunction() and OSD_Thread::Run()
now detach old thread also on platforms using pthreads.
[revision removed]
Detailed log of new commits:
Author: Author
Date: Sat Apr 15 18:57:30 2017 +0300
0028657: Foundation Classes - OSD_Thread does not release thread resources on non-Windows platforms
~OSD_Thread(), OSD_Thread::SetFunction() and OSD_Thread::Run()
now detach old thread also on platforms using pthreads.
Patch is ready for review.
No remarks, please test.
Kirill, please give results of the same measurements after the fix.
Kirill, please give results of the same measurements after the fix.
Dear Commenter 1,
Branch CR28657 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
[revision removed]
Number of compiler warnings:
occt component :
Linux: 0 (0 on master)
Windows: 0 (0 on master)
MacOS : 0 (0 on master)
products component :
Linux: 64 (64 on master)
Windows: 0 (0 on master)
MacOS : 1184
Regressions/Differences/Improvements:
http://occt-tests/CR28657-master-OCCT/Debian70-64/summary.html
Failed:
bugs modalg_5 bug23952_1, bug23952_2
bugs vis bug26404, bug26676, bug26975, bug27083, bug27337, bug28093
demo samples penrose, raytrace
v3d glsl msaa, tiles
v3d materials bug24855, bug24872_2
v3d raytrace bug24130, bug24819, bug25201, bug25221, bug25833, bug26070, bug26617, connected, plastic, refraction, sample_ball, sample_ball_alpha, sample_ball_iss, sample_cube, sample_cube_clamp, sample_cube_twosided, sample_materials, textures
Testing cases:
Not needed
Testing on Linux:
occt component :
Total MEMORY difference: 91031307 / 89994207 [+1.15%]
Total CPU difference: 19501.09000000006 / 19409.040000000256 [+0.47%]
products component :
Total MEMORY difference: 30357847 / 30341918 [+0.05%]
Total CPU difference: 5402.289999999971 / 5356.299999999965 [+0.86%]
Testing on Windows:
occt component :
Total MEMORY difference: 57805156 / 57804189 [+0.00%]
Total CPU difference: 18273.645137998592 / 18136.473458698543 [+0.76%]
products component :
Total MEMORY difference: 22303659 / 22265369 [+0.17%]
Total CPU difference: 5340.07023099997 / 5359.788757399982 [-0.37%]
There are no differences in images found by testdiff.
Branch CR28657 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
[revision removed]
Number of compiler warnings:
occt component :
Linux: 0 (0 on master)
Windows: 0 (0 on master)
MacOS : 0 (0 on master)
products component :
Linux: 64 (64 on master)
Windows: 0 (0 on master)
MacOS : 1184
Regressions/Differences/Improvements:
http://occt-tests/CR28657-master-OCCT/Debian70-64/summary.html
Failed:
bugs modalg_5 bug23952_1, bug23952_2
bugs vis bug26404, bug26676, bug26975, bug27083, bug27337, bug28093
demo samples penrose, raytrace
v3d glsl msaa, tiles
v3d materials bug24855, bug24872_2
v3d raytrace bug24130, bug24819, bug25201, bug25221, bug25833, bug26070, bug26617, connected, plastic, refraction, sample_ball, sample_ball_alpha, sample_ball_iss, sample_cube, sample_cube_clamp, sample_cube_twosided, sample_materials, textures
Testing cases:
Not needed
Testing on Linux:
occt component :
Total MEMORY difference: 91031307 / 89994207 [+1.15%]
Total CPU difference: 19501.09000000006 / 19409.040000000256 [+0.47%]
products component :
Total MEMORY difference: 30357847 / 30341918 [+0.05%]
Total CPU difference: 5402.289999999971 / 5356.299999999965 [+0.86%]
Testing on Windows:
occt component :
Total MEMORY difference: 57805156 / 57804189 [+0.00%]
Total CPU difference: 18273.645137998592 / 18136.473458698543 [+0.76%]
products component :
Total MEMORY difference: 22303659 / 22265369 [+0.17%]
Total CPU difference: 5340.07023099997 / 5359.788757399982 [-0.37%]
There are no differences in images found by testdiff.
Dear kgv,
Branch [archived branch] has been rejected due to:
- regressions/differences/improvements
Branch [archived branch] has been rejected due to:
- regressions/differences/improvements
Branch [archived branch] has been updated by Author.
[revision removed]
Detailed log of new commits:
Author: Author
Date: Mon Apr 17 20:38:45 2017 +0300
OSD_Thread::Wait() - close thread handle after joining
[revision removed]
Detailed log of new commits:
Author: Author
Date: Mon Apr 17 20:38:45 2017 +0300
OSD_Thread::Wait() - close thread handle after joining
> Kirill, please give results of the same measurements after the fix.
After patch, Ubuntu 17.04:
After patch, Ubuntu 17.04:
Private memory: 17 MiB Working Set: 84 MiB (peak: 84 MiB) Virtual memory: 324 MiB Heap memory: 4 MiB Private memory: 57 MiB Working Set: 86 MiB (peak: 86 MiB) Virtual memory: 364 MiB Heap memory: 4 MiB
Branch [archived branch] has been updated forcibly by Author.
[revision removed]
[revision removed]
Branch [archived branch] has been created by Author.
[revision removed]
Detailed log of new commits:
Author: Author
Date: Sat Apr 15 18:57:30 2017 +0300
0028657: Foundation Classes - OSD_Thread does not release thread resources on non-Windows platforms
~OSD_Thread(), OSD_Thread::SetFunction() and OSD_Thread::Run()
now detach old thread also on platforms using pthreads.
OSD_Thread::Wait() now closes thread handle after joining.
[revision removed]
Detailed log of new commits:
Author: Author
Date: Sat Apr 15 18:57:30 2017 +0300
0028657: Foundation Classes - OSD_Thread does not release thread resources on non-Windows platforms
~OSD_Thread(), OSD_Thread::SetFunction() and OSD_Thread::Run()
now detach old thread also on platforms using pthreads.
OSD_Thread::Wait() now closes thread handle after joining.
Please test updated patch.
Dear Commenter 1,
Branch CR28657_1 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
[revision removed]
Number of compiler warnings:
occt component :
Linux: 0 (0 on master)
Windows: 0 (0 on master)
MacOS : 0 (0 on master)
products component :
Linux: 64 (64 on master)
Windows: 0 (0 on master)
MacOS : 1200
Regressions/Differences/Improvements:
No regressions/differences
Testing cases:
Not needed
Testing on Linux:
occt component :
Total MEMORY difference: 92079171 / 90705102 [+1.51%]
Total CPU difference: 19888.24000000029 / 19728.220000000332 [+0.81%]
products component :
Total MEMORY difference: 30351483 / 30341918 [+0.03%]
Total CPU difference: 5373.489999999979 / 5356.299999999965 [+0.32%]
Testing on Windows:
occt component :
Total MEMORY difference: 57805223 / 57804189 [+0.00%]
Total CPU difference: 18209.528726998557 / 18136.473458698543 [+0.40%]
products component :
Total MEMORY difference: 22303677 / 22265369 [+0.17%]
Total CPU difference: 5358.946351999965 / 5359.788757399982 [-0.02%]
There are no differences in images found by testdiff.
Branch CR28657_1 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
[revision removed]
Number of compiler warnings:
occt component :
Linux: 0 (0 on master)
Windows: 0 (0 on master)
MacOS : 0 (0 on master)
products component :
Linux: 64 (64 on master)
Windows: 0 (0 on master)
MacOS : 1200
Regressions/Differences/Improvements:
No regressions/differences
Testing cases:
Not needed
Testing on Linux:
occt component :
Total MEMORY difference: 92079171 / 90705102 [+1.51%]
Total CPU difference: 19888.24000000029 / 19728.220000000332 [+0.81%]
products component :
Total MEMORY difference: 30351483 / 30341918 [+0.03%]
Total CPU difference: 5373.489999999979 / 5356.299999999965 [+0.32%]
Testing on Windows:
occt component :
Total MEMORY difference: 57805223 / 57804189 [+0.00%]
Total CPU difference: 18209.528726998557 / 18136.473458698543 [+0.40%]
products component :
Total MEMORY difference: 22303677 / 22265369 [+0.17%]
Total CPU difference: 5358.946351999965 / 5359.788757399982 [-0.02%]
There are no differences in images found by testdiff.
Dear Commenter 1,
Branch CR28657_1 is TESTED.
Branch CR28657_1 is TESTED.
Branch [archived branch] has been deleted by Author.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Author.
[revision removed]
[revision removed]