error_msg);
}
if (space != nullptr) {
+ // Check whether there is enough space left over in the data partition. Even if we can load
+ // the image, we need to be conservative, as some parts of the platform are not very tolerant
+ // of space constraints.
+ // ImageSpace doesn't know about the data partition per se, it relies on the FindImageFilename
+ // helper (which relies on GetDalvikCache). So for now, if we load an image out of /system,
+ // ignore the check (as it would test for free space in /system instead).
+ if (!is_system && !CheckSpace(*image_filename, error_msg)) {
+ // No. Delete the generated image and try to run out of the dex files.
+ PruneDalvikCache(image_isa);
+ return nullptr;
+ }
return space;
}
file.reset(OS::CreateEmptyFile(file_name));
if (file.get() == nullptr) {
+ int saved_errno = errno;
PLOG(WARNING) << "Failed to create boot marker.";
- return;
+ if (saved_errno != ENOSPC) {
+ return;
+ }
+
+ LOG(WARNING) << "Pruning dalvik cache because of low-memory situation.";
+ impl::DeleteDirectoryContents(isa_subdir, false);
+
+ // Try once more.
+ file.reset(OS::OpenFileReadWrite(file_name));
+ if (file == nullptr) {
+ PLOG(WARNING) << "Failed to create boot marker.";
+ return;
+ }
}
} else {
if (!file->ReadFully(&num_failed_boots, sizeof(num_failed_boots))) {