Javascript - 保存到磁盘的文件卡在Chrome的内存中

时间:2015-04-26 13:53:38

标签: javascript google-chrome blob file-not-found

我有这段代码:

public void onCreate(SQLiteDatabase db) {
    String CREATE_EVENT_TABLE = "CREATE TABLE " + TABLE_EVENT + "(" 
            + KEY_ID + "INTEGER PRIMARY KEY,"
            + KEY_ENAME + " TEXT,"
            + KEY_ETYPE + " TEXT,"
            + KEY_EDES + " TEXT,"
            + KEY_ESDATE + " TEXT,"
            + KEY_EEDATE + " TEXT,"
            + KEY_ESTIME + " TEXT,"
            + KEY_EETIME + " TEXT,"
            + KEY_LOCATION + " TEXT,"
            + KEY_CREATED_AT + " TEXT,"
            + KEY_EDITED_AT + " TEXT,"
            + KEY_CREATED_BY + " TEXT " + ")";
    db.execSQL(CREATE_EVENT_TABLE);
    db.execSQL("PRAGMA foreign_keys=ON;");
}

 // Upgrading database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    // Drop older table if existed
    db.execSQL("DROP TABLE IF EXISTS " + TABLE_EVENT);
    // Create tables again
    onCreate(db);
}

它可以正常使用,除了Chrome的这个问题:blob"足迹"或者在Chrome的主要流程中保留的内容'记忆。当打开下载窗口时,整个blob(在我的情况下为250MB!)被复制到主进程'记忆。这有点不好,因为如果我保存多个文件,我最终会将内存填充到750MB,然后Chrome停止下载文件" Not found"错误。图片:http://i.stack.imgur.com/j5PUn.jpg

我是做了一些愚蠢的错误还是这个Chrome的错?我可以清理Chrome的内存以解决这个问题吗?

1 个答案:

答案 0 :(得分:2)

由于my comment似乎是您正在寻找的答案,我已将其作为实际答案

点击后您没有发布 blob网址,这意味着GC无法摆脱 blob

// after the click
URL.revokeObjectURL(downloadLink.href);