CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
13.01k stars 3.51k forks source link

Big 3Dtiles Object cause memory leak #7858

Closed MagicBYang closed 5 years ago

MagicBYang commented 5 years ago

Hello developers I found a memory leak from loading big 3Dtiles Object(oblique photography) about 160GB. first I use code below to add tiles to scene

let tiles = new Cesium.Cesium3DTileset({ url:myurl, ................... }); viewer.scene.primitives.add(tiles);

But found memory take over 300MB Then I try to release by useing code below

tiles.destroy(); viewer.scene.primitives.remove(tiles);

Thougth It could release memory but in fact it is not. Then I do it repeatly add and destroy(remove) things over again,memory will never release thouth I click the Chrome GC Button.

By the way,smaller 3Dtiles Object will not casue this problem(10GB up and down) Guess This a bug so I push this Issue,Thanks to Cesium TecTeam for what you created.

OmarShehata commented 5 years ago

Thanks for reporting this @MagicBYang. Does the application eventually crash if you keep removing and adding? I ask because CesiumJS could be pooling memory, but if it's crashing it's definitely an issue.

Is this 3D Tileset hosted/created on ion?

MagicBYang commented 5 years ago

Thanks for wathcing.I checked my code eventually found I lost the some pointer on 3Dtiles during adding and remoing.Thank you for telling me about CesiumJS pooling memory thing. After testing it more times, I will describe this issue by my new testing result:

sometimes memory will release quickly after removing sometimes will not release quickly by holding it it will eventually release but no one could control it if extremes condition happen that I do adding and removing very quickly Chrome will report 'paused before potential out-of-memory crash' But most conditions it will not cause crash.

I think if 3D Tileset-class give us a method to release memory by code that will bring a better support fot big 3DTileset Object. Thanks to you again. @OmarShehata

OmarShehata commented 5 years ago

@MagicBYang was this tileset created on Cesium ion?

MagicBYang commented 5 years ago

@OmarShehata sorry It is my company's business model so I can`t push it on Cesium ion.

lzc1718 commented 5 years ago

@MagicBYang hello! I try to load 3Dtiles Object more than 100GB. But,It took several minutes to load the first time . Is there any way you can render it faster? thank you!

OmarShehata commented 5 years ago

@MagicBYang are you able to share just the tileset.json file? Or at least tell me how large it is? And what program generated it?

@lzc1718 can you open a new thread on the forum (https://groups.google.com/d/forum/cesium-dev) ? There's several reasons the tileset could be slow to load.

In any case, @MagicBYang I ask about tileset.json because regardless of the full size of the complete dataset, just adding a tileset to the scene will only request whatever is in view, and if you're benchmarking it by continually adding and immediately removing then I think that's not enough time to actually create very many primitives. Can you show me exactly the code you used that produced the crash in Chrome?

MagicBYang commented 5 years ago

1.I think now the problem is that I take pointer on this and I got lost them so the memory will never release, it is none of Cesium business.I make a software architecture to handle and extends Cesium So I must fix it now. 2.Great thanks to you @OmarShehata I am learning shader programming from your blog that give me another help. 3.Gona close this issue.

MagicBYang commented 5 years ago

@MagicBYang hello! I try to load 3Dtiles Object more than 100GB. But,It took several minutes to load the first time . Is there any way you can render it faster? thank you!

Just new Cesium.Cesium3DTileset({ url: url,
}) It is related with the program you use to conver OSGB to 3dtiles,and your CPU or GPU will effect the result. I am using "search github 'fanvanzh/3dtiles'" I am using GTX1050 and i7-7700 160GB will take only 7-8s at first. Make sure what cast most time while adding,the net transfer or rendering. If rendering take a lot of time consider give your pc a better GPU and have a try. If it does not help,you should open an new issue like OmarShehata told you that. @lzc1718