Skip to content
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

fix: 内存模式下,设置单个单元格内容格式,内存模式会失效,导致内存不断堆叠溢出 #455

Closed
mingdiantianxia opened this issue Sep 29, 2022 · 5 comments
Assignees

Comments

@mingdiantianxia
Copy link

mingdiantianxia commented Sep 29, 2022

$config     = ['path' => '/'];
$excel = new \Vtiful\Kernel\Excel($config); 
$fileObject = $excel->constMemory('test.xlsx', '内存占用', false);
for ($index = 0; $index < 10000; $index++) {
    for ($column = 0; $column < 300; $column++) {
        $mem = self::getMemoryUsage('MemRealUsage');
        $mem = $mem / (1024 * 1024);
        $fileObject->insertText($index+1, $column, floatval($mem), 'Max$#,##0.00;Max$-#,##0.00');
        var_dump($mem);
    }
}
$filePath = $fileObject->output();
$fileObject->close();
@viest viest self-assigned this Oct 9, 2022
@c-c-j
Copy link

c-c-j commented Jun 25, 2024

Hello, have you resolved this issue?

@c-c-j
Copy link

c-c-j commented Jun 25, 2024

@viest

@c-c-j
Copy link

c-c-j commented Jun 25, 2024

image
The extended and dependent versions I am using are as follows. I actively called the close method to destroy resources, but the server content remains consistent and is being added
@viest

@videni
Copy link

videni commented Aug 27, 2024

I also have this issue.

@videni
Copy link

videni commented Aug 27, 2024

You can use following example to reproduce it quickly.

<?php

// Under const memory, insertDate and insertText have the problem of memory leakage. 
// By executing the following program, you can observe the continuous growth of memory using the top command

// I also created an issue [here](https://github.com/jmcnamara/libxlsxwriter/issues/453)

$config = ['path' => __DIR__];

$excel = new \Vtiful\Kernel\Excel($config);

$filename = 'million_rows.xlsx';
$excel->constMemory($filename);
// $excel->fileName($filename);

$excel->header(['id', 'first_name', 'last_name', 'born_at']);

echo "my pid-".getmypid();

sleep(3);

$list = function() {
    for ($i = 1; $i <= 1000000; $i++) {
        yield [$i,  'Jane', 'Doe', time()];
    }
};

foreach($list() as $row) {
    $currentRow = $excel->getCurrentLine();

    $excel->insertDate(
        $currentRow,
        3,
        $row[3]
    );
    $row[3] = null;

    $excel->data([$row]);
}

$excel->output();

echo "Excel file with 1 million rows created successfully!\n";

viest added a commit that referenced this issue Aug 27, 2024
viest added a commit that referenced this issue Aug 27, 2024
viest added a commit that referenced this issue Aug 27, 2024
@viest viest closed this as completed in 927562b Aug 28, 2024
viest added a commit that referenced this issue Aug 28, 2024
fix: format memory, close #455
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants