Commit 17f0e1b
committed
fix: reduce canvas and bitmap memory by lazy-caching grids and shrinking scroll buffer
- Remove eager bitmap.cache() from _createGrid() — 8 grids were each
allocating a 1200x900x4 (~4.3 MB) backing canvas at startup even
though at most 1 grid is visible at a time (~35 MB wasted)
- Add cache(0,0,1200,900) in _show*() methods so grids are only cached
when made visible, and uncache() in _hide*() to free the backing
canvas immediately when hidden
- Skip trashed blocks in clearCache() to avoid re-creating backing
canvases for invisible blocks on every theme/resize event
- Uncache trashed block containers in sendStackToTrash() and delete
their blockArt/blockCollapseArt SVG strings to free memory
- Cap trashStacks undo history at 100 entries to prevent unbounded
growth during long editing sessions
- Reduce scroll canvas from 3x to 2x viewport dimensions in
doScrollXY(), saving ~40 MB at 1920x1080 (75 MB -> 33 MB)
- Update scroll boundary clamps to match the new 2x canvas size
Estimated RAM savings: ~70-120 MB depending on viewport size and
number of trashed blocks.1 parent f488f0b commit 17f0e1b
3 files changed
+56
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2849 | 2849 | | |
2850 | 2850 | | |
2851 | 2851 | | |
2852 | | - | |
| 2852 | + | |
| 2853 | + | |
| 2854 | + | |
| 2855 | + | |
2853 | 2856 | | |
2854 | 2857 | | |
2855 | 2858 | | |
2856 | 2859 | | |
2857 | 2860 | | |
2858 | | - | |
2859 | 2861 | | |
2860 | 2862 | | |
2861 | 2863 | | |
| |||
4672 | 4674 | | |
4673 | 4675 | | |
4674 | 4676 | | |
| 4677 | + | |
| 4678 | + | |
| 4679 | + | |
| 4680 | + | |
| 4681 | + | |
4675 | 4682 | | |
4676 | 4683 | | |
4677 | 4684 | | |
| |||
5855 | 5862 | | |
5856 | 5863 | | |
5857 | 5864 | | |
5858 | | - | |
| 5865 | + | |
5859 | 5866 | | |
5860 | 5867 | | |
5861 | 5868 | | |
| |||
5864 | 5871 | | |
5865 | 5872 | | |
5866 | 5873 | | |
| 5874 | + | |
5867 | 5875 | | |
5868 | 5876 | | |
5869 | 5877 | | |
| |||
5873 | 5881 | | |
5874 | 5882 | | |
5875 | 5883 | | |
5876 | | - | |
| 5884 | + | |
5877 | 5885 | | |
5878 | 5886 | | |
5879 | 5887 | | |
| |||
5882 | 5890 | | |
5883 | 5891 | | |
5884 | 5892 | | |
| 5893 | + | |
5885 | 5894 | | |
5886 | 5895 | | |
5887 | 5896 | | |
| |||
5942 | 5951 | | |
5943 | 5952 | | |
5944 | 5953 | | |
5945 | | - | |
| 5954 | + | |
5946 | 5955 | | |
5947 | 5956 | | |
5948 | 5957 | | |
| |||
5952 | 5961 | | |
5953 | 5962 | | |
5954 | 5963 | | |
| 5964 | + | |
5955 | 5965 | | |
5956 | 5966 | | |
5957 | 5967 | | |
| |||
6001 | 6011 | | |
6002 | 6012 | | |
6003 | 6013 | | |
6004 | | - | |
| 6014 | + | |
6005 | 6015 | | |
6006 | 6016 | | |
6007 | 6017 | | |
| |||
6011 | 6021 | | |
6012 | 6022 | | |
6013 | 6023 | | |
| 6024 | + | |
6014 | 6025 | | |
6015 | 6026 | | |
6016 | 6027 | | |
| |||
6059 | 6070 | | |
6060 | 6071 | | |
6061 | 6072 | | |
6062 | | - | |
| 6073 | + | |
6063 | 6074 | | |
6064 | 6075 | | |
6065 | 6076 | | |
| |||
6068 | 6079 | | |
6069 | 6080 | | |
6070 | 6081 | | |
| 6082 | + | |
6071 | 6083 | | |
6072 | 6084 | | |
6073 | 6085 | | |
| |||
6117 | 6129 | | |
6118 | 6130 | | |
6119 | 6131 | | |
6120 | | - | |
| 6132 | + | |
6121 | 6133 | | |
6122 | 6134 | | |
6123 | 6135 | | |
| |||
6131 | 6143 | | |
6132 | 6144 | | |
6133 | 6145 | | |
| 6146 | + | |
6134 | 6147 | | |
6135 | 6148 | | |
6136 | 6149 | | |
| |||
6180 | 6193 | | |
6181 | 6194 | | |
6182 | 6195 | | |
6183 | | - | |
| 6196 | + | |
6184 | 6197 | | |
6185 | 6198 | | |
6186 | 6199 | | |
| |||
6189 | 6202 | | |
6190 | 6203 | | |
6191 | 6204 | | |
| 6205 | + | |
6192 | 6206 | | |
6193 | 6207 | | |
6194 | 6208 | | |
| |||
6238 | 6252 | | |
6239 | 6253 | | |
6240 | 6254 | | |
6241 | | - | |
| 6255 | + | |
6242 | 6256 | | |
6243 | 6257 | | |
6244 | 6258 | | |
| |||
6248 | 6262 | | |
6249 | 6263 | | |
6250 | 6264 | | |
| 6265 | + | |
6251 | 6266 | | |
6252 | 6267 | | |
6253 | 6268 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6943 | 6943 | | |
6944 | 6944 | | |
6945 | 6945 | | |
| 6946 | + | |
| 6947 | + | |
| 6948 | + | |
| 6949 | + | |
| 6950 | + | |
| 6951 | + | |
| 6952 | + | |
6946 | 6953 | | |
6947 | 6954 | | |
6948 | 6955 | | |
| |||
6988 | 6995 | | |
6989 | 6996 | | |
6990 | 6997 | | |
| 6998 | + | |
| 6999 | + | |
| 7000 | + | |
| 7001 | + | |
| 7002 | + | |
| 7003 | + | |
| 7004 | + | |
| 7005 | + | |
| 7006 | + | |
| 7007 | + | |
| 7008 | + | |
| 7009 | + | |
| 7010 | + | |
| 7011 | + | |
| 7012 | + | |
6991 | 7013 | | |
6992 | 7014 | | |
6993 | 7015 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1366 | 1366 | | |
1367 | 1367 | | |
1368 | 1368 | | |
1369 | | - | |
1370 | | - | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
1371 | 1373 | | |
1372 | 1374 | | |
1373 | 1375 | | |
1374 | 1376 | | |
1375 | | - | |
1376 | | - | |
| 1377 | + | |
| 1378 | + | |
1377 | 1379 | | |
1378 | 1380 | | |
1379 | 1381 | | |
| |||
1383 | 1385 | | |
1384 | 1386 | | |
1385 | 1387 | | |
| 1388 | + | |
1386 | 1389 | | |
1387 | | - | |
1388 | | - | |
1389 | | - | |
| 1390 | + | |
1390 | 1391 | | |
1391 | 1392 | | |
1392 | | - | |
1393 | | - | |
1394 | | - | |
| 1393 | + | |
1395 | 1394 | | |
1396 | 1395 | | |
1397 | 1396 | | |
| |||
0 commit comments