title: Django - bulk_create() lead to memory error
body: <p>I have around 400 000 object instances to insert in postgres. I am using bulk_create() to do so, but I face a Memory error.</p>
  
  <p>My first idea was to chunk the list of instances: </p>
  
  <pre><code>def chunks(l, n):
      n = max(1, n)
      return [l[i:i + n] for i in range(0, len(l), n)]
  
  for c in chunks(instances, 1000):
      Feature.objects.bulk_create(c)
  </code></pre>
  
  <p>But sometimes that strategy also leads to Memory Error because instance's size can vary a lot, so a chunk could exceed the memory limit while others dont.</p>
  
  <p>Is it possible to chunk the list of instances in order to have chunks of delimited size? What would be the best approach in this case?</p>