---
# System prepended metadata

title: память

---

# память

```c#
using System;
using System.Collections.Generic;

class Person
{
    public Animal animal;
    public Building building;
    public int[] data;

    public Person()
    {
        data = new int[1000000];
    }
}

class Animal
{
    public string name;
    public int[] data;

    public Animal()
    {
        data = new int[100000];
    }
}

class Building
{
    public string name;
    public int[] data;

    public Building()
    {
        data = new int[100000];
    }
}

class Program
{
    // создает 1000 случайных людей
    static void Main(string[] args)
    {
        List<Person> people = new List<Person>();

        int count = 0;
        while (IsValid(count))
        {
            Person person = new Person();
            person.animal = new Animal() { name = GetRandomAnimalName() };
            person.building = new Building() { name = GetRandomBuildingName() };
            people.Add(person);
        }
    }

    static bool IsValid(int param)
    {
        return param < 100;
    }

    static string GetRandomAnimalName()
    {
        string[] animalNames = { "кошка", "собака", "хомяк", "кролик", "рыбка" };
        Random random = new Random();
        return animalNames[random.Next(animalNames.Length)];
    }

    static string GetRandomBuildingName()
    {
        string[] buildingNames = { "дом", "школа", "больница", "магазин", "театр" };
        Random random = new Random();
        return buildingNames[random.Next(buildingNames.Length)];
    }
}
```