使用数百个相同的图像时内存不足

时间:2017-03-29 22:28:33

标签: memory react-native uiimage marker react-native-maps

描述

我正在使用react-native-maps在地图上绘制约750个标记。 每个标记使用相同的图像

复制步骤和示例代码

const markerImage = <Image source={images.marker} />;
export default class Main extends Component {
  render() {
    return (
      <MapView style={StyleSheet.absoluteFill}>
        { coordinates.map(coordinate => {
          return (
            <Marker
              key={coordinate.id}
              coordinate={coordinate}
              children={markerImage}
            />
          );
        })}
      </MapView>
    )
  }
}

可能的解决方案

重新使用UIImage Optimising custom marker image performance with Google Maps SDK for iOS

但是,我不知道如何在React Native中执行此操作,因为React抽象了视图层。

其他信息

  • React Native version:[&#34; 0.41.2&#34;]
  • react-native-maps:[&#34; ^ 0.13.0&#34;]
  • 平台:[both]
  • 开发操作系统:[MacOS]
  • 开发工具:[Xcode:8.3,iPhone 7(10.3),GalaxyS6(6.0.1)]

image

image

0 个答案:

没有答案