You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Even the simplest code using react-native-tcp-socket causes increasing memory usage over time. The issue occurs with a basic TCP server that accepts connections, responds with an echo, and closes the socket immediately after responding. Despite not handling or processing any data, the server continuously increases memory usage indefinitely until Android OS kills the process and the app closes with no crash or log.
Steps to reproduce
Steps to reproduce the behavior:
Create a simple TCP server using react-native-tcp-socket that listens for client connections.
Have the server respond with an echo message and immediately close the connection.
Observe increasing memory usage over time, even with no data being processed.
Or code:
import React, { useEffect } from 'react';
import { View, Text } from 'react-native';
import TcpSocket from 'react-native-tcp-socket';
socket.on('data', () => {
console.log('Received data, but ignoring it.');
socket.write('Echo server: I got your data');
socket.end(); // Close connection immediately
});
socket.on('error', (error) => {
console.log('An error occurred with client socket:', error);
socket.destroy();
});
socket.on('close', () => {
console.log('Closed connection with', socket.address());
});
});
server.listen({ port: 3000, host: '0.0.0.0', reuseAddress: true }, () => {
console.log('Server is listening on port 3000');
});
return () => {
server.close(() => {
console.log('Server has been closed');
});
};
}, []);
return (
<View>
<Text>TCP Server is running...</Text>
</View>
);
};
export default TcpServer;
Current behavior
Even with this minimal code, memory usage increases indefinitely as the server keeps accepting and closing connections, without processing or handling the data. The server does not leak data but causes increasing memory consumption due to uncleaned resources or improper socket handling.
Expected behavior
Memory usage should remain stable, even when handling multiple connections in such a simple use case. The server should close connections properly and free resources after responding to clients, with no noticeable increase in memory consumption over time.
Relevant information
OS
Android 12
react-native
0.74.5
react-native-tcp-socket
6.2.0
Device
Physical Device
The text was updated successfully, but these errors were encountered:
Description
Even the simplest code using
react-native-tcp-socket
causes increasing memory usage over time. The issue occurs with a basic TCP server that accepts connections, responds with an echo, and closes the socket immediately after responding. Despite not handling or processing any data, the server continuously increases memory usage indefinitely until Android OS kills the process and the app closes with no crash or log.Steps to reproduce
Steps to reproduce the behavior:
react-native-tcp-socket
that listens for client connections.Or code:
Current behavior
Even with this minimal code, memory usage increases indefinitely as the server keeps accepting and closing connections, without processing or handling the data. The server does not leak data but causes increasing memory consumption due to uncleaned resources or improper socket handling.
Expected behavior
Memory usage should remain stable, even when handling multiple connections in such a simple use case. The server should close connections properly and free resources after responding to clients, with no noticeable increase in memory consumption over time.
Relevant information
The text was updated successfully, but these errors were encountered: