Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 通过颤振'发送数据;s站台频道太慢了_Java_Android_Flutter_Dart - Fatal编程技术网

Java 通过颤振'发送数据;s站台频道太慢了

Java 通过颤振'发送数据;s站台频道太慢了,java,android,flutter,dart,Java,Android,Flutter,Dart,我正在利用Flatter的平台通道将一大堆数据从Dart端发送到Java。 它是一个由393216个元素组成的Float32List,大约1.6MB 在Dart端,我使用以下函数发送数据: Future<Null> sendData(Float32List data) { _channel.invokeMethod('sendData', {'data': data}); return null; } 可能是因为在Java端,每次调用都会为传入的数据分配新的内存 所

我正在利用Flatter的平台通道将一大堆数据从Dart端发送到Java。 它是一个由393216个元素组成的Float32List,大约1.6MB

在Dart端,我使用以下函数发送数据:

  Future<Null> sendData(Float32List data) {
_channel.invokeMethod('sendData', {'data': data});
    return null;
  }
可能是因为在Java端,每次调用都会为传入的数据分配新的内存

所以我在问自己,上面提到的方法是正确的,还是有其他更有效的方法?有没有一种方法可以在不使用平台通道的情况下共享Dart和Java端具有读/写访问权限的特定内存区域

更新
如果使用Float64List而不是Float32List,它的运行会更好。我不确定这是否是一个优势,因为所有的双精度值都需要在Java端转换为浮点值。

是的,有办法,但不是最好的。我的解决方案是使用dart将数据保存在存储器中,并通过java读取文件进行操作并保存。最后从手机存储器中读取新数据。

是的,有办法,但不是最好的办法。我的解决方案是使用dart将数据保存在存储器中,并通过java读取文件进行操作并保存。最后从手机存储器中读取新数据

  @Override
  public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {

    Map<String, ?> arguments = (Map<String, ?>) call.arguments;
    if (call.method.equals("sendData")) {
}
}
I/send_data( 6306): Waiting for a blocking GC Alloc
I/send_data( 6306): Background concurrent copying GC freed 1(15KB) AllocSpace objects, 0(0B) LOS objects, 3% free, 165MB/171MB, paused 477us total 675.471ms
I/send_data( 6306): WaitForGcToComplete blocked Alloc on ProfileSaver for 256.348ms
I/flutter ( 6306): FPS 21.1287106362165615
I/send_data( 6306): Starting a blocking GC Alloc
I/send_data( 6306): Alloc concurrent copying GC freed 4665422(89MB) AllocSpace objects, 2(72MB) LOS objects, 50% free, 4MB/8MB, paused 439us total 28.436ms
I/send_data( 6306): Background concurrent copying GC freed 53274(859KB) AllocSpace objects, 0(0B) LOS objects, 9% free, 59MB/65MB, paused 995us total 116.669ms
I/send_data( 6306): Background concurrent copying GC freed 0(30KB) AllocSpace objects, 0(0B) LOS objects, 6% free, 84MB/90MB, paused 417us total 1.021s
I/send_data( 6306): Background concurrent copying GC freed 83319(1317KB) AllocSpace objects, 0(0B) LOS objects, 4% free, 132MB/138MB, paused 2.752ms total 1.096s
I/flutter ( 6306): FPS 21.1287106362165615
I/send_data( 6306): Waiting for a blocking GC Alloc
I/send_data( 6306): Background concurrent copying GC freed 2253876(43MB) AllocSpace objects, 1(36MB) LOS objects, 6% free, 86MB/92MB, paused 916us total 312.417ms
I/send_data( 6306): WaitForGcToComplete blocked Alloc on HeapTrim for 53.920ms
I/send_data( 6306): Starting a blocking GC Alloc
I/send_data( 6306): Background concurrent copying GC freed 2429155(46MB) AllocSpace objects, 1(36MB) LOS objects, 9% free, 55MB/61MB, paused 1.316ms total 227.108ms
I/flutter ( 6306): FPS 21.1287106362165615
I/flutter ( 6306): FPS 21.0497952899184655
I/send_data( 6306): Background concurrent copying GC freed 35649(581KB) AllocSpace objects, 0(0B) LOS objects, 7% free, 75MB/81MB, paused 2.148ms total 778.779ms
I/Choreographer( 6306): Skipped 418 frames!  The application may be doing too much work on its main thread.
I/flutter ( 6306): FPS 20.9614768284084351
I/send_data( 6306): Background concurrent copying GC freed 1(18KB) AllocSpace objects, 0(0B) LOS objects, 6% free, 84MB/90MB, paused 3.093ms total 820.288ms
I/flutter ( 6306): FPS 20.9112724400838368