Compare commits

...

6 Commits

Author SHA1 Message Date
Sergey Penkovsky
4953e917c9 Merge branch 'master' into develop 2026-01-15 09:00:10 +03:00
Sergey Penkovsky
1997110d92 chore(release): publish packages
- cherrypick@3.0.2
 - cherrypick_flutter@3.0.2
 - talker_cherrypick_logger@3.0.2
2025-10-20 17:31:40 +03:00
Sergey Penkovsky
0e600ca3a2 Merge pull request #25 from pese-git/issues/24
Issues/24
2025-10-20 17:28:01 +03:00
Sergey Penkovsky
25ae208ea1 fix(test): fix warning 2025-10-20 16:20:20 +03:00
Sergey Penkovsky
685c0ae49c fix(scope): properly clear binding and module references on dispose
Add memory leak/finalizer test to ensure no strong references remain after closing and disposing a scope.
2025-10-13 17:32:10 +03:00
Sergey Penkovsky
98d81b13a8 freeze deps 2025-10-13 17:26:39 +03:00
12 changed files with 129 additions and 15 deletions

View File

@@ -3,6 +3,37 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## 2025-10-20
### Changes
---
Packages with breaking changes:
- There are no breaking changes in this release.
Packages with other changes:
- [`cherrypick` - `v3.0.2`](#cherrypick---v302)
- [`cherrypick_flutter` - `v3.0.2`](#cherrypick_flutter---v302)
- [`talker_cherrypick_logger` - `v3.0.2`](#talker_cherrypick_logger---v302)
Packages with dependency updates only:
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
- `cherrypick_flutter` - `v3.0.2`
- `talker_cherrypick_logger` - `v3.0.2`
---
#### `cherrypick` - `v3.0.2`
- **FIX**(test): fix warning.
- **FIX**(scope): properly clear binding and module references on dispose.
## 2025-09-09 ## 2025-09-09
### Changes ### Changes

View File

@@ -47,7 +47,7 @@ packages:
path: "../cherrypick" path: "../cherrypick"
relative: true relative: true
source: path source: path
version: "3.0.0" version: "3.0.1"
collection: collection:
dependency: transitive dependency: transitive
description: description:

View File

@@ -1,3 +1,8 @@
## 3.0.2
- **FIX**(test): fix warning.
- **FIX**(scope): properly clear binding and module references on dispose.
## 3.0.1 ## 3.0.1
- **DOCS**: add Netlify deployment status badge to README files. - **DOCS**: add Netlify deployment status badge to README files.

View File

@@ -498,5 +498,10 @@ class Scope with CycleDetectionMixin, GlobalCycleDetectionMixin {
await d.dispose(); await d.dispose();
} }
_disposables.clear(); _disposables.clear();
// Clear modules
_modulesList.clear();
// Clear binding-index
_bindingResolvers.clear();
} }
} }

View File

@@ -1,6 +1,6 @@
name: cherrypick name: cherrypick
description: Cherrypick is a small dependency injection (DI) library for dart/flutter projects. description: Cherrypick is a small dependency injection (DI) library for dart/flutter projects.
version: 3.0.1 version: 3.0.2
homepage: https://cherrypick-di.netlify.app homepage: https://cherrypick-di.netlify.app
documentation: https://cherrypick-di.netlify.app/docs/intro documentation: https://cherrypick-di.netlify.app/docs/intro
repository: https://github.com/pese-git/cherrypick repository: https://github.com/pese-git/cherrypick

View File

@@ -0,0 +1,65 @@
import 'dart:async';
import 'package:cherrypick/cherrypick.dart';
import 'package:test/test.dart';
class HeavyService implements Disposable {
static int instanceCount = 0;
HeavyService() {
instanceCount++;
print('HeavyService created. Instance count: '
'\u001b[32m$instanceCount\u001b[0m');
}
@override
void dispose() {
instanceCount--;
print('HeavyService disposed. Instance count: '
'\u001b[31m$instanceCount\u001b[0m');
}
static final Finalizer<String> _finalizer = Finalizer((msg) {
print('GC FINALIZED HeavyService: $msg');
});
void registerFinalizer() => _finalizer.attach(this, toString(), detach: this);
}
class HeavyModule extends Module {
@override
void builder(Scope scope) {
bind<HeavyService>().toProvide(() => HeavyService());
}
}
void main() {
test('Binding memory is cleared after closing and reopening scope', () async {
final root = CherryPick.openRootScope();
for (int i = 0; i < 10; i++) {
print('\nIteration $i -------------------------------');
final subScope = root.openSubScope('leak-test-scope');
subScope.installModules([HeavyModule()]);
final service = subScope.resolve<HeavyService>();
expect(service, isNotNull);
await root.closeSubScope('leak-test-scope');
// Dart GC не сразу удаляет освобождённые объекты, добавляем паузу и вызываем GC.
await Future.delayed(const Duration(milliseconds: 200));
}
// Если dispose не вызвался, instanceCount > 0 => утечка.
expect(HeavyService.instanceCount, equals(0));
});
test('Service is finalized after scope is closed/cleaned', () async {
final root = CherryPick.openRootScope();
HeavyService? ref;
{
final sub = root.openSubScope('s');
sub.installModules([HeavyModule()]);
ref = sub.resolve<HeavyService>();
ref.registerFinalizer();
expect(HeavyService.instanceCount, 1);
await root.closeSubScope('s');
}
await Future.delayed(const Duration(seconds: 2));
expect(HeavyService.instanceCount, 0);
});
}

View File

@@ -1,3 +1,7 @@
## 3.0.2
- Update a dependency to the latest release.
## 3.0.1 ## 3.0.1
- **DOCS**: add Netlify deployment status badge to README files. - **DOCS**: add Netlify deployment status badge to README files.

View File

@@ -1,6 +1,6 @@
name: cherrypick_flutter name: cherrypick_flutter
description: "Flutter library that allows access to the root scope through the context using `CherryPickProvider`." description: "Flutter library that allows access to the root scope through the context using `CherryPickProvider`."
version: 3.0.1 version: 3.0.2
homepage: https://cherrypick-di.netlify.app homepage: https://cherrypick-di.netlify.app
documentation: https://cherrypick-di.netlify.app/docs/intro documentation: https://cherrypick-di.netlify.app/docs/intro
repository: https://github.com/pese-git/cherrypick repository: https://github.com/pese-git/cherrypick
@@ -19,7 +19,7 @@ environment:
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
cherrypick: ^3.0.1 cherrypick: ^3.0.2
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

View File

@@ -127,28 +127,28 @@ packages:
path: "../../cherrypick" path: "../../cherrypick"
relative: true relative: true
source: path source: path
version: "3.0.0" version: "3.0.1"
cherrypick_annotations: cherrypick_annotations:
dependency: "direct main" dependency: "direct main"
description: description:
path: "../../cherrypick_annotations" path: "../../cherrypick_annotations"
relative: true relative: true
source: path source: path
version: "3.0.0" version: "3.0.1"
cherrypick_flutter: cherrypick_flutter:
dependency: "direct main" dependency: "direct main"
description: description:
path: "../../cherrypick_flutter" path: "../../cherrypick_flutter"
relative: true relative: true
source: path source: path
version: "3.0.0" version: "3.0.1"
cherrypick_generator: cherrypick_generator:
dependency: "direct dev" dependency: "direct dev"
description: description:
path: "../../cherrypick_generator" path: "../../cherrypick_generator"
relative: true relative: true
source: path source: path
version: "3.0.0" version: "3.0.1"
clock: clock:
dependency: transitive dependency: transitive
description: description:
@@ -574,4 +574,4 @@ packages:
version: "3.1.3" version: "3.1.3"
sdks: sdks:
dart: ">=3.8.0 <4.0.0" dart: ">=3.8.0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54" flutter: ">=3.32.0"

View File

@@ -175,14 +175,14 @@ packages:
path: "../../cherrypick" path: "../../cherrypick"
relative: true relative: true
source: path source: path
version: "3.0.0" version: "3.0.1"
cherrypick_annotations: cherrypick_annotations:
dependency: "direct main" dependency: "direct main"
description: description:
path: "../../cherrypick_annotations" path: "../../cherrypick_annotations"
relative: true relative: true
source: path source: path
version: "3.0.0" version: "3.0.1"
cherrypick_generator: cherrypick_generator:
dependency: "direct dev" dependency: "direct dev"
description: description:
@@ -920,7 +920,7 @@ packages:
path: "../../talker_cherrypick_logger" path: "../../talker_cherrypick_logger"
relative: true relative: true
source: path source: path
version: "3.0.0" version: "3.0.1"
talker_dio_logger: talker_dio_logger:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -1131,4 +1131,4 @@ packages:
version: "2.2.2" version: "2.2.2"
sdks: sdks:
dart: ">=3.8.0 <4.0.0" dart: ">=3.8.0 <4.0.0"
flutter: ">=3.29.0" flutter: ">=3.32.0"

View File

@@ -1,3 +1,7 @@
## 3.0.2
- Update a dependency to the latest release.
## 3.0.1 ## 3.0.1
- **DOCS**: add Netlify deployment status badge to README files. - **DOCS**: add Netlify deployment status badge to README files.

View File

@@ -1,6 +1,6 @@
name: talker_cherrypick_logger name: talker_cherrypick_logger
description: A Talker logger integration for CherryPick DI to observe and log DI events and errors. description: A Talker logger integration for CherryPick DI to observe and log DI events and errors.
version: 3.0.1 version: 3.0.2
homepage: https://cherrypick-di.netlify.app homepage: https://cherrypick-di.netlify.app
documentation: https://cherrypick-di.netlify.app/docs/intro documentation: https://cherrypick-di.netlify.app/docs/intro
repository: https://github.com/pese-git/cherrypick repository: https://github.com/pese-git/cherrypick
@@ -18,7 +18,7 @@ environment:
# Add regular dependencies here. # Add regular dependencies here.
dependencies: dependencies:
talker: ^5.0.0 talker: ^5.0.0
cherrypick: ^3.0.1 cherrypick: ^3.0.2
dev_dependencies: dev_dependencies: