fixed memory leak and connection increasing bug when...
...using model
... | ... |
@@ -15,6 +15,7 @@ use DBIx::Custom::Tag; |
15 | 15 |
use DBIx::Custom::Order; |
16 | 16 |
use DBIx::Custom::Util qw/_array_to_hash _subname/; |
17 | 17 |
use Encode qw/encode encode_utf8 decode_utf8/; |
18 |
+use Scalar::Util qw/weaken isweak/; |
|
18 | 19 |
|
19 | 20 |
use constant DEBUG => $ENV{DBIX_CUSTOM_DEBUG} || 0; |
20 | 21 |
use constant DEBUG_ENCODING => $ENV{DBIX_CUSTOM_DEBUG_ENCODING} || 'UTF-8'; |
... | ... |
@@ -268,6 +269,7 @@ sub create_model { |
268 | 269 |
|
269 | 270 |
# Create model |
270 | 271 |
my $model = $model_class->new($args); |
272 |
+ weaken $self unless isweak $self; |
|
271 | 273 |
$model->name($model_name) unless $model->name; |
272 | 274 |
$model->table($model_table) unless $model->table; |
273 | 275 |
|