Comments (16)
No need to investigate IMO
I've made other tests.
Memory leak occurred in 1.38.0
and 1.38.1
but seems to be fixed in 1.38.2
We can close this issue.
Really appreciate your work on this library.
from foundry.
I donβt use a Factory to construct this object, I create an instance manually.
But it's still wrapped in a proxy? This is the part I don't understand - I don't know how this can happen.
Anyway, we're in a big aside here from the original purpose of this issue - feel free to open a second issue to discuss this proxy problem further - it is legit.
from foundry.
still eager to understand what happened here.
Hard to find the time to correctly investigate this issue in depth.
Or at least, this would be nice to know if the memory leak does not occur in v2
Just update the project to v2 and there's no memory leak anymore.
from foundry.
Hi @jdecool π
that's... surprising! π
I did not notice this problem in any project where I've tested this whole migration path π€
I track the source of the memory leak, I will update this issue.
OK, thanks, let's tackle this
from foundry.
Could it be related to all the deprecations being called? That's probably too large a spike for this to be the culprit.
from foundry.
Could it be related to all the deprecations being called? That's probably too large a spike for this to be the culprit.
I don't think that could explain the spike especially as I run the Rector Rule to fix them.
I track the source of the memory leak, I will update this issue.
I'm sorry for the delay of the investigation but I don't have much time to do this.
So I tried to update the project to Foundry 2 to see if it fix this issue.
But I have a problem.
I've a factory like this:
final class MyEntityFactory extends PersistentProxyObjectFactory
{
protected function defaults(): array|callable
{
return [
// ...
'telephoneMobile' => self::faker()->optional(0.8)->mobileNumber(),
'telephoneAutre' => self::faker()->optional(0.3)->phoneNumber(),
];
}
protected function initialize(): static
{
// see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization
return $this
->beforeInstantiate(function (array $attributes): array {
// ...
// Transform string into PhoneNumber object
$attributes['telephoneMobile'] = $this->parsePhoneNumber($attributes['telephoneMobile']);
$attributes['telephoneAutre'] = $this->parsePhoneNumber($attributes['telephoneAutre']);
return $attributes;
})
;
}
}
The parsePhoneNumber
return an instance of libphonenumber\PhoneNumber
.
In foundry 2, this object is now wrap in a proxy using the Symfony\Component\VarExporter\Symfony\Component\VarExporter
. The problem that the PhoneNumber
class already define a public function unserialize($serialized)
that is not compatible with the Symfony trait (public function __unserialize(array $data): void
).
So it will throw an exception.
I don't know how to tell Foundry to not use a proxy for this object.
from foundry.
I'm sorry for the delay of the investigation but I don't have much time to do this.
Currently I've just seen that there is a lot of strings that are staying in memory.
I'm looking for which part of the code keep those strings in memory.
from foundry.
I don't know how to tell Foundry to not use a proxy for this object.
PhoneNumber
is wrapped in a proxy? Is it an entity?
from foundry.
Yes from an external package
from foundry.
And you created a factory class for it? In foundry 2 you can have a factory extend PersistentObjectFactory
(instead of PersistentProxyObjectFactory
) and created objects won't be proxied.
FYI, we are working on some proxy improvements that should solve this issue soon.
from foundry.
I use the same library and I have the same issue. It's not a factory for this class. This class is used for a property of an entity.
The library declare the function __unserialize($data)
and LazyProxyTrait
declare the function __unserialize(array $data): void
from foundry.
Ok, I'm still not sure how PhoneNumber is being proxied. @jdecool, can you share what your parsePhoneNumber
looks like?
from foundry.
Sorry. Just realise my issue is incomplete.
Je PhoneNumber come from https://packagist.org/packages/giggsey/libphonenumber-for-php and I use https://packagist.org/packages/odolbeau/phone-number-bundle for the Symfony integration.
I donβt use a Factory to construct this object, I create an instance manually.
from foundry.
feel free to open a second issue to discuss this proxy problem further - it is legit.
β
from foundry.
still eager to understand what happened here. Or at least, this would be nice to know if the memory leak does not occur in v2
from foundry.
ok, that's nice! No need to investigate IMO
from foundry.
Related Issues (20)
- Find functions do not refresh entity HOT 2
- Attribute wrapped in a Foundry Proxy is not compatible with `Symfony\Component\VarExporter\LazyProxyTrait` HOT 6
- Foundry should not remove symfony-s errorHandlers HOT 6
- Global state relationships and flush_after HOT 13
- How to fix deprecation notices HOT 9
- [2.0] Problem with inversed `OneToOne` relationships HOT 4
- [2.0] No autocompletion for Proxy objects HOT 2
- [2.0] ResetDatabase with DamaDoctrineTestBundle and symfony/doctrine-messenger library HOT 1
- [2.0] Re-add `assertPersisted()` & `assertNotPersisted()` HOT 6
- [2.0] Customize Faker's locale HOT 6
- Foundry 2 with PHPUnit changes the error handler of Symfony HOT 4
- createMany does not work with references to third entities HOT 1
- Cannot access actual factory instance in after/before Instantiate hooks HOT 1
- Memory leak during PHPunit test with the ResetDatabase HOT 12
- Using `Zenstruck\Foundry\Test\Factories` triggers deprecations HOT 4
- Database reset randomly fails HOT 12
- DAMA 8 breaks Foundry and blocks upgrading to Symfony 7 HOT 9
- Allow to reset many databases in migrate mode HOT 9
- PHP 8.4 Support HOT 1
- [Tests] provide tests for "migration configurations"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from foundry.