Stupid question about Spring4D

Issue #42 resolved
Former user created an issue

1) Demo.Spring.ObjectContainer project does not work as expected; 2) I attached the simple project trying to use the container but it fails whatever I try.. The only way it works is when I write: GlobalContainer.RegisterType<TItem>.Implements<IItem>; GlobalContainer.RegisterType<TMyTest>.Implements<ITest>; but then on closing the application i get a whole bunch of some memory leaks coming from the Spring framework... What I am doing wrong? I read the Wiki (there are just few pages ok), but it does not help. And I do not get the meaningful difference between 6-UseContainer sample project and the attached one except that I do not put it to the different units etc..

Comments (5)

  1. Stefan Glienke repo owner

    Thanks for your report. I fixed the demo. It was the missing Build call on the container. We might improve that in the future so it either provides a meaningful error or does the missing Build call itself when calling Resolve.

    About the other error: This is related to putting your types into the dpr as that causes some issues with missing RTTI for the interface types. This RTTI is used to properly register any implemented interface of a class that is registered without explicitly stating an interface (that is why it works when you explicitly call Implements). To solve this issue just put your types into the interface section of a unit.

  2. Zigmund Bulinsh

    Thank you very much. I just thought that it can be something with rtti...but did not know what.. :)

    And what about memory leaks in case if i do the Implements manually?

  3. Stefan Glienke repo owner

    I don't see any memory leaks. However make sure you don't execute code in the dpr main. Put the code into a procedure and call that one from the main. This usually solves false memory leak reports because stuff from the dpr main does not get cleaned up properly. Same goes for things in initialization/finalization of units. Better to put the code into a routine and call that from initialization/finalization.

  4. Log in to comment