When running Expo device build, after a slightly heavy loop of console.logs, the app crashes with this:
NSMallocException
Failed to grow buffer
Logger config is as follows (using Expo FileSystem transport):
import { logger, fileAsyncTransport, consoleTransport } from 'react-native-logs';
import * as FileSystem from 'expo-file-system';
import { InteractionManager } from 'react-native';
const loggerConfig = {
async: true,
asyncFunc: InteractionManager.runAfterInteractions, // prefer performance
stringifyFunc: (msg: any) => msg, // turn off JSON.stringify for performance
transport: [fileAsyncTransport, consoleTransport],
transportOptions: {
FS: FileSystem,
fileName: 'logs___{date-today}', // Create a new file every day e.g. logs___22-10-2023
colors: { // This adds colours to the console output (not the file log)
info: 'blueBright',
warn: 'yellowBright',
error: 'redBright',
},
},
};
const log = logger.createLogger(loggerConfig);
log.patchConsole();
Note it happened when i was using JSON.stringify or with the simplified stringifyFunc. When i turned off the react-native-logs library, logging continued to work again, and the app would no longer crash. I tried with both asyncFunc as InteractionManager.runAfterInteractions and setTimeout but error occurred with both. The only way to fix it was to turn off the library.
You cannot use your simplified stringifyFunc because the msg could be complex, such as a function or an error stack. In any case, the default function should not impact performance much.
When running Expo device build, after a slightly heavy loop of console.logs, the app crashes with this: NSMallocException Failed to grow buffer
Logger config is as follows (using Expo FileSystem transport):
Note it happened when i was using JSON.stringify or with the simplified stringifyFunc. When i turned off the react-native-logs library, logging continued to work again, and the app would no longer crash. I tried with both asyncFunc as InteractionManager.runAfterInteractions and setTimeout but error occurred with both. The only way to fix it was to turn off the library.
It seems to be running out of memory. Any ideas?