Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
middleLayer_for_NJ_lite
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
middleLayer_for_NJ_lite
Commits
d8cfefff
Commit
d8cfefff
authored
Nov 23, 2023
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug: 新型释放内存
parent
d603f89e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
275 deletions
+64
-275
middleLayer_for_NJ_lite.fire
...iddleLayer_for_NJ_lite/scene/middleLayer_for_NJ_lite.fire
+39
-114
Destroyer.js
assets/middleLayer_for_NJ_lite/script/Destroyer.js
+0
-13
Destroyer.js.meta
assets/middleLayer_for_NJ_lite/script/Destroyer.js.meta
+0
-9
middleLayerBase.ts
assets/middleLayer_for_NJ_lite/script/middleLayerBase.ts
+25
-139
No files found.
assets/middleLayer_for_NJ_lite/scene/middleLayer_for_NJ_lite.fire
View file @
d8cfefff
...
...
@@ -343,19 +343,16 @@
"__id__": 512
},
{
"__id__": 514
},
{
"__id__": 524
"__id__": 522
}
],
"_active": true,
"_components": [
{
"__id__": 53
4
"__id__": 53
2
},
{
"__id__": 53
5
"__id__": 53
3
}
],
"_prefab": null,
...
...
@@ -24772,101 +24769,29 @@
},
{
"__type__": "cc.Node",
"_name": "
Destroyer
",
"_name": "
exception_pay_win
",
"_objFlags": 0,
"_parent": {
"__id__": 7
},
"_children": [],
"_active": false,
"_components": [
"_children": [
{
"__id__": 513
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "d9WooRoG1L444hPQOE3zBg"
},
{
"__type__": "ddd21vavV5OAZOK6TPHd3Je",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 512
},
"_enabled": true,
"_id": "04XtlEx3hD9J2J8VGhgzZI"
},
{
"__type__": "cc.Node",
"_name": "exception_pay_win",
"_objFlags": 0,
"_parent": {
"__id__": 7
},
"_children": [
{
"__id__": 515
},
{
"__id__": 517
},
{
"__id__": 519
}
],
"_active": false,
"_components": [
{
"__id__": 52
2
"__id__": 52
0
},
{
"__id__": 52
3
"__id__": 52
1
}
],
"_prefab": null,
...
...
@@ -24922,13 +24847,13 @@
"_name": "bg",
"_objFlags": 0,
"_parent": {
"__id__": 51
4
"__id__": 51
2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 51
6
"__id__": 51
4
}
],
"_prefab": null,
...
...
@@ -24984,7 +24909,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 51
5
"__id__": 51
3
},
"_enabled": true,
"_materials": [
...
...
@@ -25016,13 +24941,13 @@
"_name": "buy_status_text",
"_objFlags": 0,
"_parent": {
"__id__": 51
4
"__id__": 51
2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 51
8
"__id__": 51
6
}
],
"_prefab": null,
...
...
@@ -25078,7 +25003,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 51
7
"__id__": 51
5
},
"_enabled": true,
"_materials": [
...
...
@@ -25111,16 +25036,16 @@
"_name": "active_btn",
"_objFlags": 0,
"_parent": {
"__id__": 51
4
"__id__": 51
2
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 5
20
"__id__": 5
18
},
{
"__id__": 5
21
"__id__": 5
19
}
],
"_prefab": null,
...
...
@@ -25176,7 +25101,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 51
9
"__id__": 51
7
},
"_enabled": true,
"_materials": [
...
...
@@ -25208,7 +25133,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 51
9
"__id__": 51
7
},
"_enabled": true,
"_normalMaterial": null,
...
...
@@ -25276,7 +25201,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 51
4
"__id__": 51
2
},
"_enabled": true,
"alignMode": 1,
...
...
@@ -25303,7 +25228,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 51
4
"__id__": 51
2
},
"_enabled": true,
"_id": "63cvkRlSFBkLFRxtfV9h6g"
...
...
@@ -25317,16 +25242,16 @@
},
"_children": [
{
"__id__": 52
5
"__id__": 52
3
},
{
"__id__": 52
8
"__id__": 52
6
}
],
"_active": false,
"_components": [
{
"__id__": 53
3
"__id__": 53
1
}
],
"_prefab": null,
...
...
@@ -25382,16 +25307,16 @@
"_name": "bg",
"_objFlags": 0,
"_parent": {
"__id__": 52
4
"__id__": 52
2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 52
6
"__id__": 52
4
},
{
"__id__": 52
7
"__id__": 52
5
}
],
"_prefab": null,
...
...
@@ -25447,7 +25372,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 52
5
"__id__": 52
3
},
"_enabled": true,
"_materials": [
...
...
@@ -25479,7 +25404,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 52
5
"__id__": 52
3
},
"_enabled": true,
"alignMode": 1,
...
...
@@ -25506,20 +25431,20 @@
"_name": "tips",
"_objFlags": 0,
"_parent": {
"__id__": 52
4
"__id__": 52
2
},
"_children": [
{
"__id__": 52
9
"__id__": 52
7
}
],
"_active": true,
"_components": [
{
"__id__": 5
31
"__id__": 5
29
},
{
"__id__": 53
2
"__id__": 53
0
}
],
"_prefab": null,
...
...
@@ -25575,13 +25500,13 @@
"_name": "label",
"_objFlags": 0,
"_parent": {
"__id__": 52
8
"__id__": 52
6
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 5
30
"__id__": 5
28
}
],
"_prefab": null,
...
...
@@ -25637,7 +25562,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 52
9
"__id__": 52
7
},
"_enabled": true,
"_materials": [
...
...
@@ -25670,7 +25595,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 52
8
"__id__": 52
6
},
"_enabled": true,
"_materials": [
...
...
@@ -25702,7 +25627,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 52
8
"__id__": 52
6
},
"_enabled": true,
"alignMode": 1,
...
...
@@ -25729,7 +25654,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 52
4
"__id__": 52
2
},
"_enabled": true,
"alignMode": 1,
...
...
assets/middleLayer_for_NJ_lite/script/Destroyer.js
deleted
100644 → 0
View file @
d603f89e
cc
.
Class
({
extends
:
cc
.
Component
,
start
()
{
this
.
middleLayer
=
cc
.
find
(
'
middleLayer
'
).
getComponent
(
'
middleLayer
'
);
},
onDestroy
()
{
console
.
log
(
'
喵喵喵: destroyer onDestroy
'
);
this
.
middleLayer
.
clearDragonDisplayAssetList
();
}
});
assets/middleLayer_for_NJ_lite/script/Destroyer.js.meta
deleted
100644 → 0
View file @
d603f89e
{
"ver": "1.0.8",
"uuid": "ddd21bda-bd5e-4e01-938a-e933c777725e",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
assets/middleLayer_for_NJ_lite/script/middleLayerBase.ts
View file @
d8cfefff
...
...
@@ -210,38 +210,45 @@ export abstract class middleLayerBase extends cc.Component {
this
.
loadBundle
(
sceneName
,
version
,
bondleUrl
);
}
cleanMemory
()
{
// 释放骨骼动画
const
deepDrog
=
(
nd
)
=>
{
const
dragonDisplay
=
nd
.
getComponent
(
dragonBones
.
ArmatureDisplay
);
if
(
dragonDisplay
)
{
dragonDisplay
.
destroy
();
}
nd
.
children
.
forEach
(
child
=>
{
deepDrog
(
child
);
});
}
deepDrog
(
cc
.
find
(
"
Canvas
"
));
// 释放bundle
const
bd
=
cc
.
assetManager
.
getBundle
(
this
.
oldSceneName
);
bd
.
releaseAll
();
cc
.
assetManager
.
removeBundle
(
bd
);
// 释放远程加载的资源
cc
.
assetManager
.
assets
.
forEach
(
item
=>
{
if
(
item
.
nativeUrl
.
indexOf
(
`h5template`
)
==-
1
&&
item
.
nativeUrl
.
indexOf
(
`dist`
)
==-
1
&&
item
.
nativeUrl
.
indexOf
(
`http`
)
>-
1
)
{
cc
.
assetManager
.
releaseAsset
(
item
);
}
});
}
async
loadBundle
(
sceneName
,
version
,
bondleUrl
,
callback
=
null
)
{
if
(
this
.
oldSceneName
)
{
await
this
.
checkRotateScreen
(
this
.
oldSceneName
,
sceneName
);
}
this
.
assetList
=
[];
this
.
textureList
=
[];
this
.
assetObj
=
{};
this
.
atlasList
=
[];
this
.
nodeList
=
[];
this
.
getDragonDisplayAssetList
(
cc
.
find
(
'
Canvas
'
));
// this.toCleanParent();
this
.
loadBundleLock
=
true
;
// 加锁
this
.
currentBundleInfo
=
{
sceneName
,
version
,
bondleUrl
};
this
.
showWaitingLetters
();
cc
.
audioEngine
.
stopAll
();
this
.
setNodeListVisible
();
// 手机端强制垃圾回收
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
||
cc
.
sys
.
os
==
cc
.
sys
.
OS_ANDROID
)
{
cc
.
sys
.
garbageCollect
();
}
this
.
cleanMemory
();
cc
.
assetManager
.
loadBundle
(
bondleUrl
,
{
version
:
version
},
async
(
err
,
bundle
)
=>
{
bundle
.
loadScene
(
sceneName
,
null
,
(
finish
,
total
,
item
)
=>
{
this
.
setLoadingProgressBar
(
Math
.
floor
(
finish
/
total
*
100
));
},
(
err
,
scene
)
=>
{
this
.
loadBundleLock
=
false
;
// 加载完成 解锁
this
.
courseOpenTimeStamp
=
Date
.
now
();
...
...
@@ -256,17 +263,6 @@ export abstract class middleLayerBase extends cc.Component {
canvas
.
getComponent
(
cc
.
Widget
).
updateAlignment
();
middleLayer
.
scale
=
canvas
.
width
/
middleLayer
.
width
;
// 挂载清洁骨骼机制节点
const
destroyer
=
cc
.
instantiate
(
cc
.
find
(
'
middleLayer/Destroyer
'
));
destroyer
.
parent
=
cc
.
find
(
'
Canvas
'
);
destroyer
.
active
=
true
;
// 手机端强制垃圾回收
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
||
cc
.
sys
.
os
==
cc
.
sys
.
OS_ANDROID
)
{
cc
.
sys
.
garbageCollect
();
}
callback
&&
callback
();
this
.
IS_BUNDLE_LOADING
=
false
;
this
.
oldSceneName
=
sceneName
;
...
...
@@ -290,20 +286,6 @@ export abstract class middleLayerBase extends cc.Component {
}
setNodeListVisible
()
{
const
setParentVisible
=
(
n
)
=>
{
// TODO active" is not defined in the Scene, it is only defined in normal nodes
n
.
active
=
true
;
if
(
n
.
parent
)
{
setParentVisible
(
n
.
parent
);
}
}
this
.
nodeList
.
forEach
(
node
=>
{
setParentVisible
(
node
);
});
}
getUUID
()
{
return
'
xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
'
.
replace
(
/
[
xy
]
/g
,
function
(
c
)
{
var
r
=
Math
.
random
()
*
16
|
0
,
...
...
@@ -484,100 +466,4 @@ export abstract class middleLayerBase extends cc.Component {
.
start
();
}
async
clearDragonDisplayAssetList
()
{
if
(
this
.
atlasList
.
length
==
0
)
{
return
;
}
this
.
setNodeListVisible
();
for
(
let
i
=
0
;
i
<
this
.
atlasList
.
length
;
i
++
)
{
const
atlas
=
this
.
atlasList
[
i
];
const
asset
=
this
.
assetList
[
i
];
const
texture
=
this
.
textureList
[
i
];
const
node
=
this
.
nodeList
[
i
];
atlas
.
decRef
();
cc
.
assetManager
.
releaseAsset
(
atlas
);
atlas
.
destroy
();
asset
.
decRef
();
cc
.
assetManager
.
releaseAsset
(
asset
);
asset
.
destroy
();
// node.active = false;
// node.removeFromParent();
texture
.
decRef
();
}
}
// 原始方法
clearDragonDisplayAssetList3
()
{
[
...
this
.
atlasList
,
...
this
.
assetList
].
forEach
(
asset
=>
{
asset
.
decRef
();
cc
.
assetManager
.
releaseAsset
(
asset
);
asset
.
destroy
();
});
this
.
nodeList
.
forEach
(
node
=>
{
node
.
active
=
false
;
node
.
removeFromParent
();
});
this
.
textureList
.
forEach
(
texture
=>
{
texture
.
decRef
();
});
}
assetObj
=
null
;
nodeList
=
null
;
atlasList
=
null
;
assetList
=
null
;
textureList
=
null
;
getDragonDisplayAssetList
(
node
)
{
const
dragonDisplay
=
node
.
getComponent
(
dragonBones
.
ArmatureDisplay
);
if
(
dragonDisplay
)
{
const
atlas
=
dragonDisplay
.
dragonAtlasAsset
;
const
asset
=
dragonDisplay
.
dragonAsset
;
if
(
atlas
&&
atlas
.
texture
)
{
if
(
atlas
.
texture
.
nativeUrl
.
includes
(
'
h5template
'
))
{
node
.
children
.
forEach
(
child
=>
{
this
.
getDragonDisplayAssetList
(
child
);
});
return
;
}
this
.
nodeList
.
push
(
node
);
this
.
atlasList
.
push
(
atlas
);
this
.
assetList
.
push
(
asset
);
this
.
textureList
.
push
(
atlas
.
texture
);
console
.
log
(
'
汪汪汪: atlas.texture.nativeUrl =
'
+
atlas
.
texture
.
nativeUrl
);
}
}
node
.
children
.
forEach
(
child
=>
{
this
.
getDragonDisplayAssetList
(
child
);
});
}
toCleanParent
()
{
const
canvas
=
cc
.
find
(
"
Canvas
"
);
this
.
nodeList
.
forEach
(
node
=>
{
node
.
parent
=
canvas
;
});
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment