0

テキスト配列と画像配列を取り込んで、外積をツイートとして計算する「スクランブラー」を作成しています。私が心配している関数は次のようになります。

combinations: (->
  tweet_texts  = @get('tweet_texts')
  tweet_images = @get('tweet_images')

  # return empty array unless we have texts
  return Em.A([]) unless tweet_texts.length

  # handle the case when we don't have images
  unless tweet_images.length
    combinations  = tweet_texts.map (text) =>
      TwitterPost.create
        text : text
        newtwork_user : @get('account.twitter_handle')
    return Em.A(combinations)

  # handle texts and images
  combinations = tweet_images.map (image) =>
    tweet_texts.map (text) =>
      TwitterPost.create
        text  : text
        image : image
        network_user : @get('account.twitter_handle')
  return Em.A([].concat(combinations...))
).property('tweet_texts.@each','tweet_images.@each')

私の心配は、私がたくさんのモデルを作成していて、Ember のガベージ コレクションをよく理解していないことです。

では、ここでメモリリークが発生する危険がありますか?

ありがとう!

4

1 に答える 1