Open tbm98 opened 1 year ago
Description
It is my code
import 'dart:convert'; import 'dart:io'; import 'package:dart_frog/dart_frog.dart'; import 'package:http_parser/http_parser.dart'; import 'package:path/path.dart' as p; import 'package:http/http.dart' as http; import 'package:uuid/uuid.dart'; import '../main.dart'; Future<Response> onRequest(RequestContext context) async { try { final formDataRequest = await context.request.formData(); final fileUpload = formDataRequest.files.values.first.name; final timestamp = Uuid().v1(); final pathUp = p.join( Directory.current.path, 'imagesUp', timestamp.toString() + '.jpg'); final pathDown = p.join( Directory.current.path, 'imagesDown', timestamp.toString() + '.jpg'); final fbytes = await formDataRequest.files.values.first.readAsBytes(); await File(pathUp).writeAsBytes( fbytes, flush: true, ); print('upfile-ok'); return Response.bytes(body: []); } catch (e, s) { print('error- $e - $s'); return Response(statusCode: 500, body: e.toString() + s.toString()); } }
it performs the action of saving the image to the hard drive.
With 100 consecutive requests, each request uploading a 2.5MB image, the server will very quickly reach a RAM usage of about 4GB.
If the number of requests is 500 consecutive requests, the RAM usage will be more than 10GB.
Hello @tbm98 ,
Do you experience this on dev server or prod server? Or both?
@renancaraujo I just run by dart_frog dev
@tbm98 what happens if you dont run the dev server?
Description
It is my code
it performs the action of saving the image to the hard drive.
With 100 consecutive requests, each request uploading a 2.5MB image, the server will very quickly reach a RAM usage of about 4GB.
If the number of requests is 500 consecutive requests, the RAM usage will be more than 10GB.