-
Notifications
You must be signed in to change notification settings - Fork 302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Reference.OneToOne to maintain the FK field in the model with Fluent mapping causes cycles and memory leak #637
Comments
Yeh, I really should've never done any of this stuff. I've never once used it and all it causes is issues. :( |
We all have regrets in our codebases. As a side note, removing all of the Many mappings solves the issue entirely.
Unfortunately, as much as I try, I can't seem to solve this without reimplementing at least parts of the inner workings, in which case I'd rather make a pull request...
Sent from Mobile, if in doubt, blame autocorrect
…________________________________
From: Adam Schroder ***@***.***>
Sent: Friday, June 4, 2021 2:56:53 AM
To: schotime/NPoco ***@***.***>
Cc: Ilya Florenskiy ***@***.***>; Author ***@***.***>
Subject: Re: [schotime/NPoco] Using Reference.OneToOne to maintain the FK field in the model with Fluent mapping causes cycles and memory leak (#637)
Yeh, I really should've never done any of this stuff. I've never once used it and all it causes is issues. :(
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#637 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ANQXVAC7CZELWT6O3DHL2PDTRAQFLANCNFSM46BAJWVQ>.
|
Yeah, to solve it we're going to have to have a recursive limiter in there, which i do for nested complex objects, but it mustn't cover many ones. |
I actually did a bit of digging in the source and saw the limiter - unfortunately the Many fluent mapping is unaffected and, furthermore, you can't mark it as a result column, which was an example in one of the attributes based tests
Sent from Mobile, if in doubt, blame autocorrect
…________________________________
From: Adam Schroder ***@***.***>
Sent: Friday, June 4, 2021 8:50:16 AM
To: schotime/NPoco ***@***.***>
Cc: Ilya Florenskiy ***@***.***>; Author ***@***.***>
Subject: Re: [schotime/NPoco] Using Reference.OneToOne to maintain the FK field in the model with Fluent mapping causes cycles and memory leak (#637)
Yeah, to solve it we're going to have to have a recursive limiter in there, which i do for nested complex objects, but it mustn't cover many ones.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#637 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ANQXVACEGHIPN37OEMKMLH3TRBZSRANCNFSM46BAJWVQ>.
|
I may try to prepare a pull request to extend the recursion filter to .Many, would you be interested?
Sent from Mobile, if in doubt, blame autocorrect
…________________________________
From: Ilya Florenskiy ***@***.***>
Sent: Friday, June 4, 2021 9:03:39 AM
To: schotime/NPoco ***@***.***>; schotime/NPoco ***@***.***>
Cc: Author ***@***.***>
Subject: Re: [schotime/NPoco] Using Reference.OneToOne to maintain the FK field in the model with Fluent mapping causes cycles and memory leak (#637)
I actually did a bit of digging in the source and saw the limiter - unfortunately the Many fluent mapping is unaffected and, furthermore, you can't mark it as a result column, which was an example in one of the attributes based tests
Sent from Mobile, if in doubt, blame autocorrect
________________________________
From: Adam Schroder ***@***.***>
Sent: Friday, June 4, 2021 8:50:16 AM
To: schotime/NPoco ***@***.***>
Cc: Ilya Florenskiy ***@***.***>; Author ***@***.***>
Subject: Re: [schotime/NPoco] Using Reference.OneToOne to maintain the FK field in the model with Fluent mapping causes cycles and memory leak (#637)
Yeah, to solve it we're going to have to have a recursive limiter in there, which i do for nested complex objects, but it mustn't cover many ones.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#637 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ANQXVACEGHIPN37OEMKMLH3TRBZSRANCNFSM46BAJWVQ>.
|
In the end we identified the issue: The loop protection was working correctly, but our issue was that it was generating gigantic trees due to our data structure referencing the same field(s) from many points. As an example:
In this case, you already generate lots of paths due to Our solution was to limit how far the system would scan from any given column and you can see it in the pull request: |
Well thats good news. Thx. Couple of questions.
|
Apologies for the lack of comments, long weekend over here (mt-MT)
|
No problem. |
Greetings.
Given these models:
and these mappings:
This will create a gigantic memory leak as it will not recognize the owner <-> thingies as a looping relationship.
Our objective
We need to have both the column
OwnerId
and the propertyOwner
on the data model.OneToOne
used to be the way to go, but unfortunately if you then want to establish proper relationships it will eat all of your memory - so much that the Heap display will mark a bunch of places as [Cycled].(our actual app model has 17 tables mapped and spikes around 3GB of usage just for the NPOCO-powered service).
Proposed Solutions
ForeignObjectOnly
enum option which will leave to the coder the ability to declare the FK fields and throw otherwiseOneToOne
recognize looping relationships withMany
Tried:
Any suggestions are extremely welcome.
Using NPoco latest, SQL Server 2019, .NET Core currently at 3.1.latest
The text was updated successfully, but these errors were encountered: