Question: I just found that there's no LinkedList implementation in Objective-C, but I need one. So I am going to use `std::list`(or there's a better alternative?).

My question is: what should I care about memory management under ARC and non-ARC?

Answer: 
The default behavior of a many-to-many association will have an owning side and an inverse side. If you are dealing with the owning side of the association, then the association will be handled by the ORM. However if you are dealing with the inverse side, it is up to you to explicitly handle this.

In your case, you have `mappedBy="groups"` in the `$services` property of the `ServiceGroup` class. What this means is that, this association between the Service and the ServiceGroup is maintained by the `$groups` property of the `Service` entity. So, `Service` becomes the owning side of this association.

Now, say you are creating or updating a `Service` entity. Here when you add `ServiceGroup` entities to this `Service` entity, and persist the `Service` entity, all the entities and the relevant associations are automatically built by the ORM.

But, if you are creating or updating a `ServiceGroup` entity, when you add `Service` entities to it, and persist the `ServiceGroup` entity, the association is **not** built by the ORM. Here as a workaround, you have to explicitly add the `ServiceGroup` entity to the `Service` entity.

```
// in ServiceGroup.php

public function addService(Service $service)
{
    $service->addServiceGroup($this);
    $this->services->add($service);
}

// in Service.php
public function addServiceGroup(ServiceGroup $group)
{
    if (!$this->serviceGroups->contains($group)) {
        $this->serviceGroups->add($group);
    }
}

```

**Things to keep in mind**

1. Make sure that you initialize your `$services` and `$serviceGroups` to doctrine collections at the time of entity creation i.e. in the constructors.
2. You need to have `'by_reference' => false` in your `services` field in the FormType for the `ServiceGroup`.

Reference:
<http://symfony.com/doc/2.8/cookbook/form/form_collections.html>
i've done it like this: 

<http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/association-mapping.html#many-to-many-bidirectional>

and this works like a charm