This commit is contained in:
HF 2023-03-18 11:45:37 +01:00
parent 3b26d3486c
commit d6eb9510fd
6 changed files with 11 additions and 3 deletions

View File

@ -55,6 +55,7 @@ persistStore(store, {}, () => {
// for debugging
window.ppStore = store;
window.ppRender = getRenderer;
});
(function load() {

View File

@ -99,5 +99,5 @@ export const APISOCKET_USER_NAME = 'apisocket';
// maximum chunks to subscribe to
export const MAX_LOADED_CHUNKS = 2000;
export const MAX_CHUNK_AGE = 300000;
export const GC_INTERVAL = 300000;
export const MAX_CHUNK_AGE = 20000;
export const GC_INTERVAL = 20000;

View File

@ -637,6 +637,7 @@ class SocketServer {
}
deleteChunk(chunkid, ws) {
console.log('delete chunk', (chunkid >> 8) & 0x00FF, chunkid & 0x00FF, 'for', ws.user.ip);
ws.chunkCnt -= 1;
if (!this.CHUNK_CLIENTS.has(chunkid)) return;
const clients = this.CHUNK_CLIENTS.get(chunkid);
@ -646,6 +647,7 @@ class SocketServer {
deleteAllChunks(ws) {
if (!ws.chunkCnt) return;
console.logger('delete all chunks for', ws.user.ip);
// eslint-disable-next-line
for (const client of this.CHUNK_CLIENTS.values()) {
const pos = client.indexOf(ws);

View File

@ -219,6 +219,7 @@ export function requestBigChunk(center) {
}
export function removeChunks(chunks) {
console.log('remove chunks');
return {
type: 'REMOVE_CHUNKS',
chunks,

View File

@ -17,7 +17,9 @@ export default (store) => (next) => (action) => {
}
case 'REMOVE_CHUNKS': {
console.log('do');
const { chunks } = action;
console.log('deregister', chunks.filter((chunk) => chunk.recUpdates).map((chunk) => [chunk.i, chunk.j]));
const ids = chunks
.filter((chunk) => chunk.recUpdates)
.map((chunk) => chunk.id);

View File

@ -122,7 +122,9 @@ class ChunkLoader {
}
}
});
this.bcRemoveChunks(remChunks);
if (remChunks.length) {
this.bcRemoveChunks(remChunks);
}
// eslint-disable-next-line no-console,max-len
console.log(`GC cleaned ${remChunks.length} / ${chunks.size + remChunks.length} chunks`);
}