Skip to content

Commit f180ee1

Browse files
committed
Fixed a memory leak when rendering with OpenCL (noticeable when rendering animations)
1 parent ca744e7 commit f180ee1

File tree

8 files changed

+36
-20
lines changed

8 files changed

+36
-20
lines changed

release-notes.txt

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* Fixed a problem in glossy coating albedo evaluation on GPUs
2929
* Fixed a difference between CPU and GPU rendering when using a roughglass with a shadow transparency color
3030
* Fixed the support in .ply files for triangle AOVs
31+
* Fixed a memory leak when rendering with OpenCL (noticeable when rendering animations)
3132

3233
Check https://wiki.luxcorerender.org/LuxCoreRender_Release_Notes for the full list
3334
of release notes.

scenes/cornell/cornell.cfg

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ path.photongi.indirect.enabled = 0
1717
#path.photongi.indirect.lookup.radius = 0.15
1818
#path.photongi.indirect.lookup.radius = 0.0
1919
#path.photongi.indirect.glossinessusagethreshold = 0.0
20-
#path.photongi.indirect.usagethresholdscale = 0.0
20+
#path.photongi.indirect.usagethresholdscale = 8.0
2121
#path.photongi.indirect.filter.radiusscale = 4.0
2222
path.photongi.caustic.enabled = 0
2323
#path.photongi.caustic.maxsize = 10000
@@ -55,9 +55,9 @@ film.imagepipelines.0.1.value = 2.2
5555
#film.imagepipelines.1.1.type = GAMMA_CORRECTION
5656
#film.imagepipelines.1.1.value = 2.2
5757
## Optix denoiser
58-
film.imagepipelines.1.0.type = OPTIX_DENOISER
59-
film.imagepipelines.1.1.type = GAMMA_CORRECTION
60-
film.imagepipelines.1.1.value = 2.2
58+
#film.imagepipelines.1.0.type = OPTIX_DENOISER
59+
#film.imagepipelines.1.1.type = GAMMA_CORRECTION
60+
#film.imagepipelines.1.1.value = 2.2
6161
##
6262
#film.imagepipelines.0.0.type = PATTERNS
6363
#film.imagepipelines.0.0.index = 0

scenes/cornell/cornell.scn

+11-5
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,20 @@ scene.camera.fieldofview = 39.1463
1818
scene.materials.Khaki.type = matte
1919
scene.materials.Khaki.kd = 1. 0.824176 0.549451
2020
##
21+
#scene.materials.Khaki.type = glossy2
22+
#scene.materials.Khaki.kd = 0.75 0.75 0.75
23+
#scene.materials.Khaki.ks = 0.5 0.5 0.5
24+
#scene.materials.Khaki.uroughness = 0.06
25+
#scene.materials.Khaki.vroughness = 0.06
26+
############################
2127
scene.materials.HalveRed.type = matte
2228
scene.materials.HalveRed.kd = 0.70003 0. 0.
2329
##
2430
#scene.materials.HalveRed.type = glossy2
25-
#scene.materials.HalveRed.kd = 0.75 0.75 0.75
31+
#scene.materials.HalveRed.kd = 0.75 0.0 0.0
2632
#scene.materials.HalveRed.ks = 0.5 0.5 0.5
27-
#scene.materials.HalveRed.uroughness = 0.21
28-
#scene.materials.HalveRed.vroughness = 0.21
33+
#scene.materials.HalveRed.uroughness = 0.06
34+
#scene.materials.HalveRed.vroughness = 0.06
2935
##scene.materials.HalveRed.photongi.enable = 1
3036
##
3137
#scene.materials.HalveRed.type = glossy2
@@ -66,8 +72,8 @@ scene.materials.DarkGreen.kd = 0. 0.4 0.
6672
#scene.materials.DarkGreen.type = glossy2
6773
#scene.materials.DarkGreen.kd = 0.0 0.0 0.0
6874
#scene.materials.DarkGreen.ks = 0.5 0.95 0.5
69-
#scene.materials.DarkGreen.uroughness = 0.051
70-
#scene.materials.DarkGreen.vroughness = 0.051
75+
#scene.materials.DarkGreen.uroughness = 0.06
76+
#scene.materials.DarkGreen.vroughness = 0.06
7177
#scene.materials.DarkGreen.photongi.enable = 1
7278
##
7379
scene.materials.Light.type = matte

src/luxrays/accelerators/bvhaccelhw.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ class BVHKernel : public HardwareIntersectionKernel {
236236
delete program;
237237
}
238238
virtual ~BVHKernel() {
239+
delete kernel;
240+
239241
for (u_int i = 0; i < vertsBuffs.size(); ++i)
240242
device.FreeBuffer(&vertsBuffs[i]);
241243
for (u_int i = 0; i < nodeBuffs.size(); ++i)

src/luxrays/accelerators/mbvhaccelhw.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ class MBVHKernel : public HardwareIntersectionKernel {
270270
}
271271

272272
virtual ~MBVHKernel() {
273+
delete kernel;
274+
273275
for (u_int i = 0; i < vertsBuffs.size(); ++i)
274276
device.FreeBuffer(&vertsBuffs[i]);
275277
for (u_int i = 0; i < nodeBuffs.size(); ++i)

src/luxrays/accelerators/optixaccelhw.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,8 @@ class OptixKernel : public HardwareIntersectionKernel {
551551
virtual ~OptixKernel() {
552552
CUDAIntersectionDevice *cudaDevice = dynamic_cast<CUDAIntersectionDevice *>(&device);
553553

554+
delete optixEmptyAccelKernel;
555+
554556
if (optixPipeline) {
555557
CHECK_OPTIX_ERROR(optixPipelineDestroy(optixPipeline));
556558
}

src/slg/scene/parsetextures.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -606,13 +606,13 @@ Texture *Scene::CreateTexture(const string &texName, const Properties &props) {
606606
const float width = props.Get(Property(propName + ".width")(0.f)).Get<float>();
607607

608608
tex = new WireFrameTexture(width, bordertTex, insideTex);
609-
} else if (texType == "bevel") {
609+
/*} else if (texType == "bevel") {
610610
const Texture *bumpTex = props.IsDefined(propName + ".bumptex") ?
611611
GetTexture(props.Get(Property(propName + ".bumptex")(1.f))) : nullptr;
612612
613613
const float radius = props.Get(Property(propName + ".radius")(.025f)).Get<float>();
614614
615-
tex = new BevelTexture(bumpTex, radius);
615+
tex = new BevelTexture(bumpTex, radius);*/
616616
} else
617617
throw runtime_error("Unknown texture type: " + texType);
618618

tests/pymemoryleaktest/pymemoryleaktest.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,18 @@ def SceneOps():
5050
scene = pyluxcore.Scene("scenes/luxball/luxball-hdr.scn", 1.0)
5151

5252
def RenderConfigOps():
53-
renderConfig = pyluxcore.Scene("scenes/luxball/luxball-hdr.cfg", 1.0)
53+
props = pyluxcore.Properties("scenes/luxball/luxball-hdr.cfg")
54+
config = pyluxcore.RenderConfig(props)
5455

5556
def SimpleRender():
5657
# Load the configuration from file
5758
props = pyluxcore.Properties("scenes/luxball/luxball-hdr.cfg")
5859

59-
# Change the render engine to PATHCPU
60-
props.Set(pyluxcore.Property("renderengine.type", ["PATHCPU"]))
61-
#props.Set(pyluxcore.Property("opencl.devices.select", ["0100"]))
60+
# Change the render engine
61+
props.Set(pyluxcore.Property("renderengine.type", ["PATHOCL"]))
62+
props.Set(pyluxcore.Property("opencl.devices.select", ["01000"]))
63+
props.Set(pyluxcore.Property("film.hw.enable", ["0"]))
64+
props.Set(pyluxcore.Property("opencl.native.threads.count", [0]))
6265

6366
config = pyluxcore.RenderConfig(props)
6467
session = pyluxcore.RenderSession(config)
@@ -78,15 +81,15 @@ def SimpleRender():
7881
session.Stop()
7982

8083
# Save the rendered image
81-
session.GetFilm().Save()
84+
#session.GetFilm().Save()
8285

8386

8487
################################################################################
8588

8689
def MemoryUsage():
8790
import psutil
8891
process = psutil.Process(os.getpid())
89-
mem = process.get_memory_info()[0]
92+
mem = process.memory_info()[0]
9093
return mem
9194

9295
def PropertiesTest():
@@ -169,9 +172,9 @@ def main():
169172

170173
print("LuxCore %s" % pyluxcore.Version())
171174

172-
PropertiesTest()
173-
SceneTest()
174-
RenderConfigTest()
175+
#PropertiesTest()
176+
#SceneTest()
177+
#RenderConfigTest()
175178
SimpleRenderTest()
176179

177180
if __name__ == '__main__':

0 commit comments

Comments
 (0)